Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Staging Flat File with Quotes as Text Qualifier

Author  Topic 

GhantaBro
Posting Yak Master

215 Posts

Posted - 2009-07-13 : 12:29:00
Hey Guys,

I am using bulk-insert command to stage flat files delmited with comma or pipe with quotes as text qualifier... the problem i sthe text qualifier.... is there anything that I can use in bulk-insert as the parameter that can ignore those quotes when staging the data? I am sure lot of people have been asking this... sorry.

GhantaBro
Posting Yak Master

215 Posts

Posted - 2009-07-13 : 12:36:23
Guys this will be automated process and we are not using SSIS or DTS for staging the file.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-13 : 13:37:11
cant you use format file for specifying delimiters?

http://www.nigelrivett.net/SQLTsql/BCP_quoted_CSV_Format_file.html
Go to Top of Page

GhantaBro
Posting Yak Master

215 Posts

Posted - 2009-07-13 : 14:34:01
Problem is we cannot create format file that easily as every file can have different number of fields in it.
Go to Top of Page

GhantaBro
Posting Yak Master

215 Posts

Posted - 2009-07-13 : 17:37:20
First row has column names.
Go to Top of Page

GhantaBro
Posting Yak Master

215 Posts

Posted - 2009-07-13 : 17:39:28
KeyCode, MemAcctNum, NATitle, NName
205509,0505488528,,"Rip, Winkle"
205501,0505488111,,"Tiger, Scott"

Sample data.

Quotes only for fields that has embedded comma.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-07-13 : 22:18:41
Search for FnParseLists Function. It will solve your Problem.
Go to Top of Page

GhantaBro
Posting Yak Master

215 Posts

Posted - 2009-07-13 : 23:36:59
Thanks Sodeep nice function, but I think using "," as the column delimiter in bulk insert and doing select into another table and using replace or substring to get rid off " from first and last fields would do the trick.
Go to Top of Page

GhantaBro
Posting Yak Master

215 Posts

Posted - 2009-07-14 : 13:05:23
Hard to deal with Quotes only for those fields that has embedded comma... sample above. anyone with such experience pls.
Go to Top of Page

GhantaBro
Posting Yak Master

215 Posts

Posted - 2009-07-14 : 16:08:21
Has anyone use LogParser to import "true CSV"?
Go to Top of Page
   

- Advertisement -