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.
Author |
Topic |
sql_server_dba
Posting Yak Master
167 Posts |
Posted - 2011-03-30 : 14:09:38
|
All Experts,Need small help in here with the bcp format. I have a CSV file with the column delemiter as , and my data is shown in the below format...abc,"pqr,ccc",xyzaaa,"bbb,ccc",dddso the above data has only 3 columns but has 4 ,'s because of which the import is not getting the correct data into the fields.. is there any workaround for this(other than changing the file to other delimiters)?i am using the below bcp commant to import...bcp dbname..test_table in C:\test_file.txt -c -t,-T _SServernameplease let me know the changes which i may need to do for this in order to import if possible? |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
ajthepoolman
Constraint Violating Yak Guru
384 Posts |
Posted - 2011-03-30 : 14:15:26
|
It would be a goofy way to do it, but I would probably take a stab at a universal search and replace. First would be to replace ," with |"then I would try ", with "|In theory that would leave the comma between the values in the second column. I know you specifically said you wanted a workaround other than switching delimiters, but this might be the most efficient way.Hey, it compiles. |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-03-30 : 14:18:31
|
In a dos box run BCP /? to see the possible switches.Maybe it is the switch -q No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
sql_server_dba
Posting Yak Master
167 Posts |
Posted - 2011-03-30 : 16:28:56
|
Thanks all for quick reply. I will ask the vendor to send the file with other delimiter. |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-03-30 : 22:36:10
|
or you can use using OPENROWSETSELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Text;HDR=No;Database=C:\', 'SELECT * FROM [test_file.txt]') KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|