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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 bcp format

Author  Topic 

dgaylor
Yak Posting Veteran

54 Posts

Posted - 2005-03-11 : 12:30:24
Is there any way to bcp/bulk insert a csv file that has a field that is sometimes empty. Sometimes there is a value within quotes like "216" and sometimes there is nothing. When I try to bcp I get an error. The following is a sample of the data. The 4th field is causing me the issue. Thanks.

"P","L","1","4","C","C","9","6"
"J","J","2",,"C","C","9","9"
"C","P","1","2","C","C","9",""
"S","B","5",,"C","C","9","6"

X002548
Not Just a Number

15586 Posts

Posted - 2005-03-11 : 13:09:36
Where is the data coming from?

Have them fix the feed



Brett

8-)
Go to Top of Page

nosepicker
Constraint Violating Yak Guru

366 Posts

Posted - 2005-03-11 : 13:14:09
What is your bulk insert/bcp statement? Try creating a staging table with columns that are all varchar/char datatypes (and they accept NULLs). Then use something like this:

bcp databasename..stagingtablename in path\filename -c -t"," -Uuserid -Ppassword -Sservername

This will bcp the double quotes in as well. Then just update the columns to get rid of the double quotes and then populate your actual table.
Go to Top of Page
   

- Advertisement -