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)
 DTS

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-02-16 : 08:18:48
Kobus writes "I have a procedure where I import data from a text file. Part of it uses the following lines:

Bulk Insert TEMP_Input
From 'C:\myFolder\myFile.txt'
With (FIELDTERMINATOR = '|',ROWTERMINATOR = ';')
GO

The above line works fine.

What I need is to be able to insert different file names into to the string - replacing the variable @myFile

Bulk Insert TEMP_Input
From 'C:\myFolder\'+@myFile+'.txt'
With (FIELDTERMINATOR = '|',ROWTERMINATOR = ';')
GO

Nothing seems to work after days of many apostrophies...
Any suggestions?"

jcragle
Starting Member

2 Posts

Posted - 2005-02-18 : 10:49:43
Declare @SQL varchar(4000)
set @SQL = 'Bulk Insert TEMP_Input From C:\myFolder\'+@myFile+'.txt
With (FIELDTERMINATOR = ''|'',ROWTERMINATOR = '';'')'
exec (@SQL)
Go to Top of Page
   

- Advertisement -