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
 SQL Server Development (2000)
 Weird Error Message When doing a fetch in a cursor

Author  Topic 

scullee
Posting Yak Master

103 Posts

Posted - 2003-02-08 : 19:57:25
I am having problems with a stored procedure that is doing freakish things.

I grabbed some of the code from here and it worked last nite but all of a sudden it is giving me weird errors. I want to process all files in a directory. I found the code to put the directory listing into the table and i create a cursor to loop through each file. I have attached the code below


INSERT INTO #Directory_Listing (FDFFileName)
EXEC master.dbo.xp_cmdshell @Dircommand

--Create cursor for files to work through
DECLARE DIR_CURSOR CURSOR FOR (SELECT FDFFileName FROM #Directory_Listing)

Print 'Opening Cursor'
OPEN DIR_CURSOR
Print 'Cursor Open'

Print 'Fetch'
FETCH NEXT FROM DIR_CURSOR INTO @CurrentFilename

Print 'Fetch Status'
select @Files = 0
WHILE @@FETCH_STATUS = 0
BEGIN
-- More Code here


The It all works fine and the print statements are there to tell me where the code is. Between 'Fetch' and the 'Fetch Status' the database is returning

Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near ')'.

If i comment the line out the error goes away but it doesnt do the first fetch.

This one is really strange and i have no idea whats going on. I am running sql server 7sp4 (and i reapplied the service pack) Does anyone have any ideas?

   

- Advertisement -