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:02pm

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:17pm

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 1:59am

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

Other recent topics Other recent topics