Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bulk insert error-help needed

Status
Not open for further replies.

eja2000

Programmer
Nov 30, 2003
209
NG
this is my bulk insert code...


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


 
thanks..
i did that now i get another error;

--------------------------

Server: Msg 4832, Level 16, State 1, Line 1
Bulk Insert: Unexpected end-of-file (EOF) encountered in data file.
Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'STREAM' reported an error. The provider did not give any information about the error.
The statement has been terminated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top