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)
 bulk insert error

Author  Topic 

femig
Starting Member

5 Posts

Posted - 2004-05-25 : 02:42:01
this is my code that gives an error;



CREATE proc spImportRegData

AS

CREATE TABLE #T
(o varchar(8000))
insert into #T
EXEC MASTER..xp_cmdshell 'dir D:\Site\log\*.rpt'
delete from #T WHERE o not like '%batch_registration%'
delete from #T WHERE o IS NULL
select right(o,45) from #T

DECLARE @filename varchar(100)
DECLARE @sql varchar(5000)

DECLARE fileCursor Cursor for
SELECT right(o,45) AS o FROM #T
OPEN fileCursor

FETCH NEXT FROM fileCursor INTO @filename
while @@fetch_status=0
Begin
SET @sql = 'BULK INSERT adp2sql.dbo.[RegisteredSubscribers] FROM ''D:\Site\log\' + @filename + ''' WITH (FIELDTERMINATOR =''|'',ROWTERMINATOR =''\n'')'
print @sql
exec @sql
FETCH NEXT FROM fileCursor INTO @filename
END
Close fileCursor
Deallocate fileCursor
-----------------------------------------------------

The error i get is;

(9 row(s) affected)


(5 row(s) affected)


(3 row(s) affected)


(1 row(s) affected)

BULK INSERT adp2sql.dbo.[RegisteredSubscribers] FROM 'D:\Site\Tavia\batch_registration_update_20040521_205002.rpt' WITH (FIELDTERMINATOR ='|',ROWTERMINATOR ='\n')
Server: Msg 203, Level 16, State 2, Procedure spImportRegData, Line 25
The name 'BULK INSERT adp2sql.dbo.[RegisteredSubscribers] FROM 'D:\Site\Tavia\batch_registration_update_20040521_205002.rpt' WITH (FIELDTERMINATOR ='|',ROWTERMINATOR ='\n')' is not a valid identifier.


Can anyone help? i have been battling with this and i cant seem to see a way round it...

thanks
   

- Advertisement -