Bulk Insert into Predefined Table

  •     I am trying to load a fixed length .txt file into a already defined table using bulk insert. The  extension name of the file changes every day, so i came up with a routine to figure out which file i need to load. However the sql server table has more fields that the fixed length flat flat file, how do I map the fixed length fields from the flat file to the corresponding fields in the sql server 2000 table using bulk insert or some other sql command.

     

     

    Thanks yocasta


    Anthony Malone

  • You will have to use format files for loading more or less fields into a table through Bulk Insert.

    Read BOL on format files for bcp.

    http://qa.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=192560#bm192593

    For different file names you have to use Dynamic SQL

    Regards,
    gova

  • To obtain a Format File you can use this command

    bcp MyDB..MyTable format test.txt -f "ExportFormat.fmt"  -c -t \t -r\n -S MyServer -T

     

    because your data is fixed length you will have to modify a little the file to obtain your new format for import


    Kindest Regards,

    Vasc

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply