Bulk Insert doesn't load

I have a Bulk insert that doesn't load but doesn't error,

SET @SQL= 'BULK INSERT dbo.LexisNexis_import_BANKRUPTCY FROM ''' + @ImportFile + ''' WITH (FIRSTROW = 2, FORMATFILE = ''' + @FormatFilePath +  ''' )'

EXEC(@SQL)


		
				

All columns in the csv are double quoted so I stip them out in a format file.

There is data in the source file. Any Ideas why this Isn't working?

Thanks!

Mike

 
July 31st, 2015 6:05pm

What is the error you are getting? or are you not getting an error?

If you format your BULK INSERT command manually and run it outside of EXEC (@SQL) does it work?

BULK INSERT dbo.LexisNexis_import_BANKRUPTCY FROM 'C:\file.csv' WITH (FIRSTROW = 2,FORMATFILE='C:\formatfile.xml'); GO

I obvioulsy made up the file names 

Free Windows Admin Tool Kit Click here and download it now
July 31st, 2015 6:19pm

Try like this one:

DECLARE @bulk_cmd varchar(1000);
SET @bulk_cmd = 'BULK INSERT AdventureWorks2012.Sales.SalesOrderDetail
FROM ''<drive>:\<path>\<filename>'' 
WITH (ROWTERMINATOR = '''+CHAR(10)+''')';
EXEC(@bulk_cmd);

Source: https://msdn.microsoft.com/en-IN/library/ms188365.aspx

August 1st, 2015 2:02am

My crystal ball is broken, so I will need to ask you to post:

1) The CREATE TABLE statement you are using.
2) You format file.
3) A sample data file that demonstrates the problem you are seeing.

Since the data file may be sensitive to the exact bytes, the best if you upload this somewhere (SkyDrive, Dropbox etc).

Free Windows Admin Tool Kit Click here and download it now
August 1st, 2015 4:26am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics