Bulk insert .csv - fieldterminator

sql sqlbulkcopy

Question

I have .csv which content is like this

"aa839","340000","2350444"

When I do the BULK INSERT, I use FIELDTERMINATOR = ',' Thus, the data has quote ".

I want to remove the quote ", so that my database has only aa839, 340000, 2350444.

1
1
10/7/2015 1:18:00 AM

Accepted Answer

Dont bother about replacing while doing bulk insert , you can replace later after bulk insert . So do bulk insert as it is originally and later fire update query as below. This is the fastest way too

update table set field= REPLACE(field, 'search', 'replace');

where search is "" and replace is blank

-1
12/5/2013 8:47:20 AM

Popular Answer

here's how to do it with powershell:

Get-Content inputfilename | 
Foreach-Object {$_ -replace '\"', ''} | 
Set-Content outputfilename


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow