[dba-SQLServer] Bulk insert

Eric Barro ebarro at verizon.net
Tue May 1 09:22:34 CDT 2007


The link I sent in one of my email responses actually addressed the "
issue...

http://www.thescripts.com/forum/thread520822.html

Specifically...

-------
9;Some unquoted data;12;9.234;2004-12-12
19;"Some quoted data";-12;31.4;2003-02-23

But if a text column is consistently quoted, you can handle this with a
format file where you specify each field. A format file that fits the
second row in the example above could look like:

8.0
5
1 SQLCHAR 0 0 ";\"" 1 col1 ""
2 SQLCHAR 0 0 "\";" 2 col2 ""
3 SQLCHAR 0 0 ";" 3 col3 ""
4 SQLCHAR 0 0 ";" 4 col3 ""
5 SQLCHAR 0 0 "\r\n" 5 col3 "" 

-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of JWColby
Sent: Tuesday, May 01, 2007 6:29 AM
To: dba-sqlserver at databaseadvisors.com
Subject: [dba-SQLServer] Bulk insert

I am trying to to use the bulk insert to pull csv file data in to a table.
It appears that I have everything except for the fact that the data is
enclosed in "" - "SomeData".  This is common in CSV files in order to "wrap"
commas which would otherwise be interpreted as a field delimiter.  Bulk Copy
has a Line Terminator and a Field terminator as a parameter but I do not see
anyplace to specify what is known as a "Text qualifier" (the " surrounding
the data).
 
Is there ANY way to do this?  CSV files are very common and text qualifiers
are so common that the import / export wizard allows you to specify them.
Surely bulk insert must understand them.
 
John W. Colby
Colby Consulting
www.ColbyConsulting.com
 
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.467 / Virus Database: 269.6.2/782 - Release Date: 5/1/2007 2:10
AM
 




More information about the dba-SQLServer mailing list