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
 General SQL Server Forums
 New to SQL Server Programming
 what's wrong with my cursor?

Author  Topic 

smorty44
Yak Posting Veteran

93 Posts

Posted - 2007-08-24 : 13:54:09
My cursor never stops, what am I missing?

Declare @Ip_FileName nvarchar(255)
Declare @Ip_Active char(1)

Declare ActiveFile Cursor For
Select Ip_FileName, Ip_Active from tln_InputFiles
where Ip_Active = 'Y'

Open ActiveFile
Fetch Next From ActiveFile
Into @Ip_FileName, @Ip_Active

While @@Fetch_Status = 0
Begin
-- Delete data for this client...
Exec('truncate table tri_'+ @Ip_FileName)

End

CLOSE ActiveFile
DEALLOCATE ActiveFile

sshelper
Posting Yak Master

216 Posts

Posted - 2007-08-24 : 13:59:25
You are missing the FETCH inside the WHILE loop

While @@Fetch_Status = 0
Begin
-- Delete data for this client...
Exec('truncate table tri_'+ @Ip_FileName)
Fetch Next From ActiveFile
End

SQL Server Helper
http://www.sql-server-helper.com
Go to Top of Page

smorty44
Yak Posting Veteran

93 Posts

Posted - 2007-08-24 : 14:17:47
Thank you!
Go to Top of Page
   

- Advertisement -