July 30, 2009 at 9:23 am
Hello,
I have a proplem with BULK in stored procedures.
I want to do a BULK from a file (.CSV) wich name changes every day. So I have an attribute “@FileName” in order to change the name every single day.
BULK INSERT dbo.TableName
FROM @FileName
WITH ( FIELDTERMINATOR=’;', ROWTERMINATOR=’\’)
But it gives me an error telling that there’s a sintax error after FROM. I have tried with all kind of punctuation (’,”,`,´,+)
It would be gratefull if some one could answer to my question.
Thanks in advance
July 30, 2009 at 10:12 am
saved in my snippets: bulk insert will not accept a variable, so you need to use the EXEC command instead:
--bulk insert won't take a variable name, so make a sql and execute it instead:
set @sql = 'BULK INSERT BULKACT FROM ''' + @path + @filename + ''' '
+ ' WITH (
DATAFILETYPE = ''char'',
FIELDTERMINATOR = '','',
ROWTERMINATOR = '''',
FIRSTROW = 2
) '
print @sql
exec (@sql)
Lowell
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply