September 18, 2006 at 7:43 am
Hi,
I want to use a bulk insert statement in a stored procedure, but instead of using a string to pass the location of the file I want to use a parameter to pass in the file name.
Below is my code but I get an incorrect syntax error with the line: from @fileLocation
Does this mean that you can't use a parameter in this situation? Or have I just coded it incorrectly?
DECLARE @fileLocation varchar(100)
SET @fileLocation = 'C:\ExciteUpload\Amazon\' + @fileName
BEGIN TRAN
Bulk Insert Amazon_Orders
from @fileLocation
with
(ROWTERMINATOR ='\n',
BATCHSIZE = 50000,
CODEPAGE = 'ACP',
FIRSTROW = 2)
COMMIT TRAN
Any help would be much appreciated.
Cheers
Reet
September 18, 2006 at 7:55 am
Have you tried putting everything in dynamic sql and run it like that??
I think it's like the problem with : "use @MyDbname" >> can't work without dynamic sql.
September 18, 2006 at 8:21 am
Cheers
Seems to have done the trick!
September 18, 2006 at 8:36 am
Great. I'm still opened to other suggestions since I ain't no expert in the matter.
September 18, 2006 at 10:32 pm
You are now 'cause that's the way to do it...
--Jeff Moden
Change is inevitable... Change for the better is not.
September 19, 2006 at 4:42 am
If you insist .
I'll let Jeff explain this new nickname .
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply