sql-server-2005bulk-import

How to import data with double quotes in SQL Server 2005


I have to import a text file with data which contains double quotes. Actually I have created a text file which contains aix commands and their explanation.

Now the commands contains double quotes. So using the regular approach of importing bulk data into SQL Server 2005 I am getting error.

My text file is like:

1,acledit "file",for changing the ACL(access control list) of a file
2,anacheck -ap,error analysing for Escala E + T
3,bsh,starts a born shell
4,cancel "print job number",for killing a print job
5,chgrp "group" "file",changes the group of a file
6,chitab "inittab statement",for disabling a statement of the /etc/inittab
7,chmod 0777 "file",gives everybody the right to read, write and execute the specified file
8,chown "user" "file",changes the owner of a file
9,compress -v "file",compresses a file
10,cplv,copies a logical volume (no mirroring)

Can someone plz guide me how to import this data as it is in SQL Server 2005?


Solution

  • Use BULK INSERT with the FIELDTERMINATOR option

    bulk insert [yourtablename] from 'yourfilepath' with (fieldterminator = ',')