SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Importing a csv file into a database - inserts quotes automatically into every field


Importing a csv file into a database - inserts quotes automatically into every field

Author
Message
mrichardson 57577
mrichardson 57577
SSC Rookie
SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)

Group: General Forum Members
Points: 27 Visits: 83
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
jerry-621596
jerry-621596
Mr or Mrs. 500
Mr or Mrs. 500 (595 reputation)Mr or Mrs. 500 (595 reputation)Mr or Mrs. 500 (595 reputation)Mr or Mrs. 500 (595 reputation)Mr or Mrs. 500 (595 reputation)Mr or Mrs. 500 (595 reputation)Mr or Mrs. 500 (595 reputation)Mr or Mrs. 500 (595 reputation)

Group: General Forum Members
Points: 595 Visits: 646
Which transformation and destination components are you using?
anthony.green
anthony.green
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10139 Visits: 6367
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
When a question, really isn't a question - Jeff Smith
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


mrichardson 57577
mrichardson 57577
SSC Rookie
SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)

Group: General Forum Members
Points: 27 Visits: 83
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...'
anthony.green
anthony.green
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10139 Visits: 6367
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
When a question, really isn't a question - Jeff Smith
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


mrichardson 57577
mrichardson 57577
SSC Rookie
SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)

Group: General Forum Members
Points: 27 Visits: 83
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.
anthony.green
anthony.green
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10139 Visits: 6367
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
When a question, really isn't a question - Jeff Smith
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


jerry-621596
jerry-621596
Mr or Mrs. 500
Mr or Mrs. 500 (595 reputation)Mr or Mrs. 500 (595 reputation)Mr or Mrs. 500 (595 reputation)Mr or Mrs. 500 (595 reputation)Mr or Mrs. 500 (595 reputation)Mr or Mrs. 500 (595 reputation)Mr or Mrs. 500 (595 reputation)Mr or Mrs. 500 (595 reputation)

Group: General Forum Members
Points: 595 Visits: 646
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.
anthony.green
anthony.green
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10139 Visits: 6367
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
When a question, really isn't a question - Jeff Smith
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


Philip-1144230
Philip-1144230
SSC Rookie
SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)

Group: General Forum Members
Points: 44 Visits: 50
Thanks for reporting back what caused it. Helped me with something else entirely.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search