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
 Import/Export (DTS) and Replication (2000)
 Dynamic file name in Bulk Insert?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-01-06 : 08:26:27
Deepak writes "Hello,

Can we give the dynamic file name to bulk insert command?

I tried the following code :

DECLARE @FILEPATH NVARCHAR(100)
SET @FILEPATH='''c:\Mydata.txt'''
DECLARE @QUERY NVARCHAR(4000)


bulk insert [XYZ.dbo.MyTable] FROM + @FILEPATH

Any alternative to achieve this?

Thanks in advance.

Deepak."

RoyalSher
Yak Posting Veteran

95 Posts

Posted - 2005-01-10 : 06:03:12
Deepak, I was wondering what is the problem you have while the script is run? I believe the above code would do your job, and have it executed through a dynamic sql statement either using exec or sp_executesql.

Hope this little info helps!

RoyalSher.
*********
The world is the great gymnasium where we come to make ourselves strong.
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2005-01-10 : 07:07:18
declare @sql varchar(1000)
select @sql = 'bulk insert [XYZ.dbo.MyTable] FROM ' + @FILEPATH
exec (@sql)


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -