How to insert specific column values into a table using BULK INSERT?

  • Hi

    I am having table Tbl1 which contains 4 columns (id,name,firstname,lastname).

    I have to insert values from data.txt file having | seperator.

    data.txt file contains 10 columns,from those 10 columns i need to insert 1,4,6,8,9 column values.

    How to insert specific column values into a table using BULK INSERT?

    Thanks

  • Books Online says you should use a format file, so I would try that first.

    Or simply

    INSERT TargetTable (Col1, Col2, Col3, Col4)

    SELECT ColBlue, ColGreen, ColRed, ColWhite

    FROM OPENROWSET (....) AS c


    N 56°04'39.16"
    E 12°55'05.25"

  • Thanks

    Hi How the format file would be for above ?

    Where i have to specify source column name destn column name?

  • sharma (6/11/2008)


    Hi How the format file would be for above ?

    Since we don't know your column name nor the file layout you will have to do some work for yourself now. Please read BOOKS ONLINE for more help about format file.

    sharma (6/11/2008)


    Where i have to specify source column name destn column name?

    This is also explained in detail in Books Online. Please read BOOKS ONLINE for more help about format file.


    N 56°04'39.16"
    E 12°55'05.25"

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

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