I'm trying to import a CSV file to a database using the BULK command. I've created a small procedure that accepts two parameters - path to CSV file and Table to insert data to.
CREATE PROC import_excel
(@tblName VARCHAR(10), @path VARCHAR(100))
DECLARE @cmd VARCHAR(200)
SET @cmd = 'BULK INSERT '+ @tblName +
' FROM ' + @path +
FIRSTROW = 2 ,
MAXERRORS = 0 ,
FIELDTERMINATOR = '','',
ROWTERMINATOR = ''\n''
But I am unable to execute it. It throws Incorrect syntax near ' ' I'm pretty sure it has something to do with concatenating strings and parameters, I just can't figure out the problem.