Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Variable in a Bulk Insert Statement

Author  Topic 

orosario
Starting Member

1 Post

Posted - 2005-07-28 : 09:32:24
I need to include a variable in a Bulk Insert statement, when I do it the query analizer doesn't accept the variable... Please Help Me..

Here is the code :

bulk insert tblForms FROM @Path


where @Path is of a variable type nvarchar(128)...

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-28 : 09:38:47
something like this
declare @File varchar(100)
declare @SQL varchar(300)
set @File='''D:\test.txt'''
print @File

Set @SQL ='bulk insert TableName from '+@File+' WITH (
DATAFILETYPE = ''char'',
FIELDTERMINATOR = '' '',
TABLOCK
)'

exec (@SQL)


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -