Wednesday, March 7, 2012

Importing data from a text file with quotes

Dear all,

I trying to import a set of datas from a text file to a table call Movement.

Table structure for Movement is as following:

1, JobNo, Character (10)
2, Date, smalldatetime
3, ItemDesc, Character (100)
4, StaffID, Character (5)
5, Quantity, Decimal(10,4)
6, Completed,Bit

text file sample contains:

"T200601100";1/10/2006;"A3 papers, Plastic covers","T1001",500,1
"T200601101";1/11/2006;"Ink Refiller for MF0012/3","T1001",5.5,1
"T200601102";1/12/2006;"1' roller","T1012",50,1
"T200601103";1/13/2006;"A1 Papers White, A3 Paper Black","T1022",500,1
"T200601104";1/13/2006;"Folders","T1022",10,1


Now the problem is when i use bulk insert statement i put in the double quote (""") into the fields too. How can i solve this problem out?

Thanks in advance.You can use a format file with bcp/bulk insert to import data that contains field delimiters. You have to basically create dummy columns in the format file for the delimiter which you will ignore. See books online for more details on how to use format file with more columns than that of the table.

No comments:

Post a Comment