Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Bulk Insert , Ms Sql ..

  • 27-05-2008 01:37PM
    #1
    Closed Accounts Posts: 1,788 ✭✭✭


    Hey ,
    is there a way to use BULK INSERT and specify the column you want the data from the file to go into ?

    I have
    CREATE TABLE tmp_table (line text)
    
    BULK INSERT tmp_table FROM 'E:\shared\DOCM\e\4707621.txt'
    WITH (ROWTERMINATOR = '|\eof' )
    
    which works ..

    but i can't specify more columns in the tmp_table
    like this won't work..
    CREATE TABLE tmp_table (line text,id int)
    
    BULK INSERT tmp_table(line) FROM 'E:\shared\DOCM\e\4707621.doc'
    WITH (ROWTERMINATOR = '|\eof' )
    


Comments

  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    Try using BCP instead...


  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    Read the documentation on the BULK INSERT statement and look for the word FIELDTERMINATOR and/or the word FORMATFILE :)


Advertisement