LIFEEXPERT
asked on
How do I fix this bulk insert
I am getting this error:
The bulk load failed. The column is too long in the data file for row 1, column 3. Verify that the field terminator and row terminator are specified correctly.
I have this proc(Llisted below) to insert into a 3 column table.The text being inserted looks like this:
123456798|12/03/2003|03/19 /2004|7412 58963|12/1 5/2003|01/ 14/2004|85 2147963|12 /15/2003|0 1/14/2004|
Table definition looks like this
ID VARCHAR(9), BEG_BEG, VARCHAR(10), END_DATE VARCHAR(10)
Where am I going wrong?
Thanks
The bulk load failed. The column is too long in the data file for row 1, column 3. Verify that the field terminator and row terminator are specified correctly.
I have this proc(Llisted below) to insert into a 3 column table.The text being inserted looks like this:
123456798|12/03/2003|03/19
Table definition looks like this
ID VARCHAR(9), BEG_BEG, VARCHAR(10), END_DATE VARCHAR(10)
Where am I going wrong?
Thanks
ALTER PROCEDURE dbo.IMPORT_file
(@DataFileName sysname ='C:\data.TXT' )
AS
/* SET NOCOUNT ON */
DECLARE @SQLCommand VARCHAR ( 1012 )
SELECT @SQLCommand = 'Bulk INSERT tmptable FROM ''' + @DataFileName + ''' with ( FIELDTERMINATOR=''|'', ROWTERMINATOR = ''|\n'' ) '
PRINT @SQLCommand
EXEC ( @SQLCommand )
RETURN
ASKER
I thought the same thing..."Your problem is that your file has several rows of data per row", but when I cut and past this into MSword it puts the line return in and divides the data into correct rows; as if I just couldn't see it in Notepad. Any idea why?
Hmmm. Maybe it wants the old-school terminator "\r\n"?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You have several options: clean up the file (blech), create an SSIS package and insert that way (by splitting by the columns), or use the attached code (source for the base of the code: http://forums.databasejournal.com/showthread.php?t=47966) to read the file, parse out the 3 pieces of each row's data in the rows, and insert that way.
hth
valkyrie_nc
Open in new window