Import data from comma delimited text file into an SQL Server table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • silpa
    New Member
    • May 2007
    • 20

    Import data from comma delimited text file into an SQL Server table

    I have a comma delimited text file which has data like this.

    1, 11, "abc" ,False
    2, 12, "def" ,False
    3, 13, "ghi" ,False
    4, 14, "jkl" ,False
    The name of this file is somedata.txt. Only one column has double quotes.
    i.e., "abc" "def" etc.

    I want to store these values into a table named temp in SQL Server.
    I am using bulk insert.

    BULK INSERT temp FROM 'D:\somedata.tx t' WITH
    (
    FIELDTERMINATOR = ',',
    ROWTERMINATOR=' \n'
    )

    How to remove double quotes so that the data will be stored into table as
    1,11,abc,0 (Here 0 refers that the column data type is bit).

    Kindly help me regarding this.

    Thanks,
    Silpa
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Try using a format file.


    -- CK

    Comment

    Working...