Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BULK INSERT - Passing filename as variable 1

Status
Not open for further replies.

DavidKnight

Programmer
Mar 31, 2004
27
CA
Hi All;

Here's todays issue. I have been able to execute the following Bulk Insert.

BULK INSERT DATA_FILE_TEST
FROM 'C:\Work\DataFile.csv'
WITH (formatfile='c:\work\DataFile.fmt',
firstrow=1,
lastrow=1);

Now I want to pass the csv file as a variable and have been unsuccessful. Even tried ''' + @file + ''', I'm missing something obviously.
Error is: Line 14: Incorrect syntax near '@file'.

DECLARE @file sysname
SET @file = 'C:\Work\DataFile.csv'
BULK INSERT DATA_FILE_TEST
FROM @file
WITH (formatfile='c:\work\DataFile.fmt',
firstrow=1,
lastrow=1);

Thanks In advance!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top