Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server 2008 - General
»
Importing a csv file into a database -...
18 posts, Page 1 of 2
1
2
»»
Importing a csv file into a database - inserts quotes automatically into every field
Rate Topic
Display Mode
Topic Options
Author
Message
mrichardson 57577
mrichardson 57577
Posted Tuesday, January 08, 2013 9:18 AM
Grasshopper
Group: General Forum Members
Last Login: Monday, February 04, 2013 10:13 AM
Points: 19,
Visits: 61
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
jerry-621596
jerry-621596
Posted Wednesday, January 09, 2013 1:03 PM
Old Hand
Group: General Forum Members
Last Login: Yesterday @ 11:18 AM
Points: 364,
Visits: 580
Which transformation and destination components are you using?
Post #1404965
anthony.green
anthony.green
Posted Thursday, January 10, 2013 1:48 AM
SSCertifiable
Group: General Forum Members
Last Login: Friday, April 12, 2013 3:51 AM
Points: 5,075,
Visits: 4,831
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
mrichardson 57577
mrichardson 57577
Posted Thursday, January 10, 2013 3:40 AM
Grasshopper
Group: General Forum Members
Last Login: Monday, February 04, 2013 10:13 AM
Points: 19,
Visits: 61
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
anthony.green
anthony.green
Posted Thursday, January 10, 2013 3:44 AM
SSCertifiable
Group: General Forum Members
Last Login: Friday, April 12, 2013 3:51 AM
Points: 5,075,
Visits: 4,831
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
mrichardson 57577
mrichardson 57577
Posted Thursday, January 10, 2013 3:57 AM
Grasshopper
Group: General Forum Members
Last Login: Monday, February 04, 2013 10:13 AM
Points: 19,
Visits: 61
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
anthony.green
anthony.green
Posted Thursday, January 10, 2013 4:07 AM
SSCertifiable
Group: General Forum Members
Last Login: Friday, April 12, 2013 3:51 AM
Points: 5,075,
Visits: 4,831
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
jerry-621596
jerry-621596
Posted Thursday, January 10, 2013 11:16 AM
Old Hand
Group: General Forum Members
Last Login: Yesterday @ 11:18 AM
Points: 364,
Visits: 580
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
anthony.green
anthony.green
Posted Friday, January 11, 2013 1:22 AM
SSCertifiable
Group: General Forum Members
Last Login: Friday, April 12, 2013 3:51 AM
Points: 5,075,
Visits: 4,831
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
Philip-1144230
Philip-1144230
Posted Friday, January 11, 2013 1:25 AM
Grasshopper
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 »
18 posts, Page 1 of 2
1
2
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.