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.
| 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 + @FILEPATHAny 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. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-01-10 : 07:07:18
|
| declare @sql varchar(1000)select @sql = 'bulk insert [XYZ.dbo.MyTable] FROM ' + @FILEPATHexec (@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. |
 |
|
|
|
|
|