 |
|
 |
|
Next: GHD Precious Gift Set
|
| Author |
Message |
External

Since: Jul 27, 2010 Posts: 1
|
(Msg. 1) Posted: Tue Jul 27, 2010 1:53 pm
Post subject: bulk insert troubles Archived from groups: comp>databases>ms-sqlserver (more info?)
|
|
|
Hello,
I am trying to load a csv file using bulk insert. Everything goes fine
but no data is loaded! All I get is a message saying "(0 row(s)
affected)". Any idea what s going on?
Set up:
create table dbo.test (member_id varchar (50),
prod_name varchar(50), prod_score varchar(50))
SQL:
bulk insert dbo.test
from 'C:/temp/test.csv'
with (FIRSTROW = 2,FORMATFILE = 'C:/temp/my-format.fmt')
Format File: my-format.fmt
9.0
3
1 SQLCHAR 0 50 "\",\"" 1 member_id SQL_Latin1_General_CP1_CI_AS
2 SQLCHAR 0 50 "\",\"" 2 prod_name SQL_Latin1_General_CP1_CI_AS
3 SQLCHAR 0 50 "\"\r\n" 3 prod_score SQL_Latin1_General_CP1_CI_AS
Data file:
2,a,3
2,b,1
2,c,5
3,a,3
3,b,4
3,c,0 >> Stay informed about: bulk insert troubles |
|
| Back to top |
|
 |  |
External

Since: May 30, 2004 Posts: 2061
|
(Msg. 2) Posted: Tue Jul 27, 2010 6:25 pm
Post subject: Re: bulk insert troubles [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
( ) writes:
> I am trying to load a csv file using bulk insert. Everything goes fine
> but no data is loaded! All I get is a message saying "(0 row(s)
> affected)". Any idea what s going on?
>...
> Format File: my-format.fmt
> 9.0
> 3
> 1 SQLCHAR 0 50 "\",\"" 1 member_id
SQL_Latin1_General_CP1_CI_AS
> 2 SQLCHAR 0 50 "\",\"" 2 prod_name
SQL_Latin1_General_CP1_CI_AS
> 3 SQLCHAR 0 50 "\"\r\n" 3 prod_score
SQL_Latin1_General_CP1_CI_AS
>
>
> Data file:
> 2,a,3
> 2,b,1
> 2,c,5
> 3,a,3
> 3,b,4
> 3,c,0
The format file does not match the data file. The file uses only comma
as delimiter, but according to your format file, the file is expected
to look like this:
2","a","3"
2","b","1"
2","c","5"
3","a","3"
3","b","4"
3","c","0"
--
Erland Sommarskog, SQL Server MVP, esquel DeleteThis @sommarskog.se
Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx >> Stay informed about: bulk insert troubles |
|
| Back to top |
|
 |  |
| Related Topics: | bulk insert in clustered index table - Hi, I have got the following situation please give me some ideas how to solve/work around it. Current situation: Everyday day about 10 million records are processed and bulk inserted in individual tables. Around 20K records are inserted at a time. At..
Trying to insert a zero, its telling me i cannot insert a .. - Hi. I am trying to insert a zero into the below table and I am being told that: Cannot insert the value NULL into column 'UsageToday', table DB.dbo.Pub_Count'; column does not allow nulls. UPDATE fails. The statement has been terminated. What I am..
Performing Bulk Load of XML Data - I found this quite interesting. However, it seems to assume I have a schema defined in an xsd or xdr file. I get a data feed that appears to be well formed XML, but there is no schema. Is it possible to bulk load XML data without a schema file being..
Email on insert in a table - Hi, I wish to use email functionality of sql to send me an email when an insert is performed on a particular table. I know that a proc and may be a trigger is required. Can someone please provide me some hints. Thanks, Guju
Insert Into Select trouble - I've tried for hours... and my issue is this: Table 1 has FirstName, LastName, Address, Birthday, (and other columns) Table 2 has FirstName, LastName, Address, Birthday, (and other columns) Most of Table1.Birthday is null. Some are not. All of.. |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|