473,387 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Load csv file into a table

3
All,

When I try to load data into a table using a csv file I get below errors.

Expand|Select|Wrap|Line Numbers
  1. bulk insert client_key
  2. from 'T:\CLIENT_KEY.txt'
  3. WITH (
  4.     FIELDTERMINATOR =',',
  5.     ROWTERMINATOR = '\r\n',
  6.     DATAFILETYPE  = 'widenative')
Msg 4866, Level 16, State 4, Line 1
The bulk load failed. The column is too long in the data file for row 1, column 1. Verify that the field terminator and row terminator are specified correctly.
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".

Sample of file, first 2 lines

Expand|Select|Wrap|Line Numbers
  1. 56QS2LttX5P3DVN5WQVcOWyk5Y=,vIXIFDGBDVK62m2Ka6/yuPLCJMc=,2010-07-01 00:00:00.000,2019-09-09 00:00:00.000,NULL,NULL,NULL,NULL,NULL
  2. 5A7OUtuTDodcn59DhimXhpCFRQw=,7D751838D2D3DVZ5Q97A22FB6945F1FE559578681D0478815D3436A7DD1B14352,2009-01-01 00:00:00.000,2019-01-01 00:00:00.000,NULL,NULL,NULL,NULL,key2
Thank you all in advance.
Sep 26 '12 #1
5 4871
Rabbit
12,516 Expert Mod 8TB
I think the error message is fairly clear. It's saying the first row, first column in the text file is too long to fit in the table field it's trying to insert into.
Sep 26 '12 #2
uksql
3
But the value I a mtrying to insert is very small.
Below is the create table stmt.

Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE [dbo].[CLIENT_KEY](
  2.     [CLNT_REF_ID] [varchar](256) NOT NULL,
  3.     [CLIENT_KEY] [varchar](256) NULL,
  4.     [START_DATE] [datetime] NULL,
  5.     [END_DATE] [datetime] NULL,
  6.     [USM_CREATOR] [varchar](10) NULL,
  7.     [USM_CREATE_TS] [datetime] NULL,
  8.     [USM_UPDATOR] [varchar](50) NULL,
  9.     [USM_UPDATE_TS] [datetime] NULL,
  10.     [ENC_KEY] [varchar](50) NULL
  11. ) ON [PRIMARY]
Sep 26 '12 #3
Rabbit
12,516 Expert Mod 8TB
Are you using SQL Server 2005 before cumulative update 4? Because apparently it's a known bug. http://support.microsoft.com/kb/942660

It suggests using ASCII instead of Unicode as a workaround.
Sep 26 '12 #4
uksql
3
Rabbit - but my version of SQL Serverin which I am trying to insert is 2008 R2 not 2005.


And thank you next time i'll make sure I use code snippets.
Sep 27 '12 #5
Rabbit
12,516 Expert Mod 8TB
I would try using ASCII anyways to see if that resolves the issue. Especially since your field in the table is ASCII but you're using unicode to read your text file.
Sep 27 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Soul | last post by:
Hi, I have a DataGrid which works. But if I load a new table to the DataGrid, it will still show those old data I load earlier. private void loadTableA() { if ( openFileDialog.ShowDialog()...
6
by: chris | last post by:
Hi, I have a table in the database. I have a method which will return a table with the same structure as the DB one and with all data I need. What I want to do is to remove all data in the DB...
2
by: Eric Falsken | last post by:
Eric Falsken <eric@db4o.com> wrote on 04 Dec 2005: > craigkenisston@hotmail.com wrote on 19 Nov 2005: > >> I'm working in the migration of an asp.net application in 1.1 to 2.0. >> I'm new to...
1
by: urs | last post by:
Two days ago, I built an ASP.NET 2.0 application and published it on a shared IIS 6 Web server. After publishing, and during the whole day, it worked fine. The server remained untouched since....
1
by: Dan | last post by:
Environment: Win2k Server, ASP.NET(v1.1.4322) Everything seemed to work fine till this morning...and than this happened What could this possibly mean? Is it the file? (The file in the error...
1
by: ddelaney | last post by:
I've seen this posted before in many places, but have yet to find a real fix. I have a web application on dev server right now, and randomly, hours or days, it returns the expception posted below. ...
4
by: CPD | last post by:
From PHP, doing a DROP TABLE and a CREATE TABLE is successful, but doing a LOAD FILE keeps failing, with the error "Access denied for user 'db_user'@'localhost' (using password: YES)". The...
4
by: Richard Bysouth | last post by:
Hi I am running a site built on asp.net 1.1 on a windows server 2003 (which is running asp.net 2.0 - shared hosting at my webhost). The site is low traffic and very simple (mostly static text...
0
by: dave.dolan | last post by:
I haven't changed the code I'm running for a long time, and it's been working. Now, starting yesterday, I keep getting an error randomly when I load my site. It doesn't happen every time, but...
2
by: antonyliu2002 | last post by:
I am testing AJAX. I've downloaded the AJAX Extension and the CTP December package and installed on BOTH my development machine and the production server. Then I created a very very simple web...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.