July 25, 2006 at 6:48 am
I am using the following code for bulkinsert
alter Procedure SelFile
(
@FileName char(50)
)
As
SET NOCOUNT ON
BULK INSERT EmpInput FROM 'E:\FileTransfers\Inputs\Emp\' +@FileName+' .txt'
GO
but getting this error.
Server: Msg 170, Level 15, State 1, Procedure SelFile, Line 29
Line 29: Incorrect syntax near '+'.
July 25, 2006 at 6:55 am
Try
EXEC('BULK INSERT EmpInput FROM ''E:\FileTransfers\Inputs\Emp\' + @FileName + '.txt''')
Far away is close at hand in the images of elsewhere.
Anon.
July 25, 2006 at 6:58 am
I tried it, it says file not found but when run bulkinsert out of SP it loads the file
July 26, 2006 at 12:06 pm
Check and make sure ''E:\FileTransfers\Inputs\Emp\' + @FileName + '.txt''') exists on the SERVER instead of client, and check if read permission is assigned to the user running this SP
July 26, 2006 at 12:08 pm
alter Procedure SelFile
(
@FileName char(50)
)
As
SET NOCOUNT ON
SET @FileName='E:\FileTransfers\Inputs\Emp\' +@FileName+' .txt'
BULK INSERT EmpInput FROM @FileName
GO
Vasc
July 26, 2006 at 4:25 pm
Bulk insert is expecting the E drive where the file resides to be on the SQL Server. If it's not, you can specify the location like \\yourservername\directory\filename.txt
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply