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 2008 Forums
 Transact-SQL (2008)
 Csv import throught DTS?

Author  Topic 

akpaga
Constraint Violating Yak Guru

331 Posts

Posted - 2015-02-12 : 12:38:40
Hi Friends,

When i am trying to import csv file to my table in Sql Server ,
the csv file has column customer_Chemicals where the data is like this

2,4 nitro Chloride
3,1 Sodium Chloride

So when i do this file import the data is getting split at the comma and the rest fo it is being saved in the next field which makes the data to be mispalced in all columns...Can someone please suggest how to avoid this ..Thank you

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2015-02-12 : 13:22:54
How are you trying to import it? Assuming you are using SSIS or Import/Export Wizard, there are only two ways that I know of to avoid this type of behavior:

a) Use something else other than comma as your delimiter, so there is no ambiguity as to whether a comma is part of the data or a delimiter.

b) escape the data items that have embedded commas using an escape character (typically double-quotes), and specify the escape character (in import/export wizard or SSIS). Eg.
"2,4 nitro Chloride"
"3,1 Sodium Chloride"
Go to Top of Page
   

- Advertisement -