Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Importing a csv file into a database - inserts quotes automatically into every field Expand / Collapse
Author
Message
Posted Tuesday, January 8, 2013 9:18 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, September 6, 2013 4:06 AM
Points: 27, Visits: 82


We are using a SSIS package to insert a series of CSV files (saved in excel) into a database table.

The problem is, the SSIS package inserts " quotes before every entry into every field imported.

There are no quotes in the CSV files at all, yet they appear in the database.

The SSIS package uses a Multiple Flat File connection, Row delimiter is {CR}{LF}.

Is there a quick and easy way in SSIS package or in the database to stop the quotes from being inserted?

thanks
Post #1404322
Posted Wednesday, January 9, 2013 1:03 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 1:58 PM
Points: 367, Visits: 615
Which transformation and destination components are you using?
Post #1404965
Posted Thursday, January 10, 2013 1:48 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Monday, October 13, 2014 6:42 AM
Points: 5,216, Visits: 5,111
You will need to set a text qualifier on the source csv file connection manager.

Excel will auto remove them when looking at the csv file as it knows " is a text qualifier, I bet if you open the file in notepad they will show, or even using the preview screen on the connection manager.




Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1405266
Posted Thursday, January 10, 2013 3:40 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, September 6, 2013 4:06 AM
Points: 27, Visits: 82
jerry-621596 (1/9/2013)
Which transformation and destination components are you using?

In my data flow, I have a Flat File Source which connect to a
OLE DB Destination

anthony.green (1/10/2013)
You will need to set a text qualifier on the source csv file connection manager.
... I bet if you open the file in notepad they will show.


Yes, you are right, I can now see the quotes in notepad.
As for the Text Qualifier... In the Multiple Flat Files Connection Manager Editor, under the General tab, the Text qualifier box was set to <none> I have tried putting in a quotes " and double quotes "" to no avail - the import job fails (if thats what you mean?).

And inserting quotes in the text qualifier also warns me that 'the flat file parser does not support embedding text qualifiers in data...'
Post #1405317
Posted Thursday, January 10, 2013 3:44 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Monday, October 13, 2014 6:42 AM
Points: 5,216, Visits: 5,111
If it speach marks " (double quote), the text qualifer should just be a speach mark, you dont want to wrap it up into a string so '"' (single, double, single)

If that doesnt work are you able to share the file so I can take a look.




Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1405319
Posted Thursday, January 10, 2013 3:57 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, September 6, 2013 4:06 AM
Points: 27, Visits: 82
I have tried just " on its own, and that didn't work - import fails.

example of the content (when the database is set to limit data entries to 9 characters):

"AB123AB"
"AB12 AB"

an example of the import (when the database is set to limit data entries to 8 characters):
"AB123AB
"AB12 AB

above examples are when there is no text qualifier.

With " (1 set of double quotes) it fails.

Also tried the above with the database character limit to 7 , 8 and 9 - still either shows quotes or import fails.

here are 2 example files (as a series of these csv files are being imported)
http://www.sypensions.org.uk/webcomponents/ab.csv
http://www.sypensions.org.uk/webcomponents/b.csv
- it is just the first column which is being imported.

thanks.
Post #1405326
Posted Thursday, January 10, 2013 4:07 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Monday, October 13, 2014 6:42 AM
Points: 5,216, Visits: 5,111
mrichardson 57577 (1/10/2013)
I have tried just " on its own, and that didn't work - import fails.

example of the content (when the database is set to limit data entries to 9 characters):

"AB123AB"
"AB12 AB"

an example of the import (when the database is set to limit data entries to 8 characters):
"AB123AB
"AB12 AB

above examples are when there is no text qualifier.

With " (1 set of double quotes) it fails.

Also tried the above with the database character limit to 7 , 8 and 9 - still either shows quotes or import fails.

here are 2 example files (as a series of these csv files are being imported)
http://www.sypensions.org.uk/webcomponents/ab.csv
http://www.sypensions.org.uk/webcomponents/b.csv
- it is just the first column which is being imported.

thanks.


Ah post code data, what a lot of fun I have had in the past getting this kind of information.

Looking from the data though there shouldnt be an issue in getting that imported.

Can you attach your SSIS package solution as a zip file, or atleast the CREATE TABLE command for the table your inserting the data into.




Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1405330
Posted Thursday, January 10, 2013 11:16 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 1:58 PM
Points: 367, Visits: 615
If you would post a sample of the csv file, and a create table script, I will see if I can figure it out. Sounds like a setting issue in one of the components.
Post #1405571
Posted Friday, January 11, 2013 1:22 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Monday, October 13, 2014 6:42 AM
Points: 5,216, Visits: 5,111
Hopefully resolved this via PM, took a look at the OP's SSIS package and was what I looked at setup incorrectly.

Detailed to use a ForEach loop to pick up each file individualy and import, as the flat file connection manager was looking at *.csv instead of ab.csv etc.




Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1405802
Posted Friday, January 11, 2013 1:25 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, May 10, 2013 9:33 AM
Points: 14, Visits: 50
Thanks for reporting back what caused it. Helped me with something else entirely.
Post #1405806
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse