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
 SQL Server Development (2000)
 BULK INSERT / BCP / DTS?

Author  Topic 

sqldba20
Posting Yak Master

183 Posts

Posted - 2007-12-03 : 12:15:35
Folks:

I need help using Bulk INSERT or BCP. I have the following file with a comma (,) as a seperator. I used Bulk Insert but with bulk insert it inserts the rows along with the double quotes ("). Also, with bulk insert at the 2nd rows because the column has money seperated by comma it assumes it as 2 columns. Any help with writing a bcp or bulk is appreciated. I could have used DTS but the input file name keeps on changing and so I cannot use DTS.

FILE:
-----

"20071567","","PAID CITIBANK N.A. FOR GOLDMAN SACHS ","_CASH",""
"20071435","","REDEMPTION OF 10,000,000 GENERAL ELEC","_CHEQUE","10"
"20072335","TIME","DEBENTURES OF 5,000 BLOOMBERG","_CASH","0"



Thanks !

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-12-03 : 12:40:01
Try creating a format file and use it in BCP parameters..

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2007-12-03 : 12:47:16
Have a look at
http://www.nigelrivett.net/SQLTsql/BCP_quoted_CSV_Format_file.html

At the bottom is an example of importing quote delimitted strings.
Another option is to import into a single column tabvle then parse the data as in
http://www.nigelrivett.net/SQLTsql/f_GetEntryDelimiitted.html

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -