Site Search:
Sign in | Join | Help
4Penny.net

SQL Server (T-SQL)

Comments and notes on SQL Server 2000, 2005, and T-SQL

Cursor Template

This is the cursor template that I use... it works better than the default one, and allows BREAK and CONTINUE easily

 DECLARE curName CURSOR LOCAL FAST_FORWARD FOR 
 select *
  from mytablename
DECLARE variables
OPEN curName
WHILE 1=1 
BEGIN
 FETCH NEXT FROM curSopUpdate23 INTO @sopnumbe,@soptype,@dtOnTruck, @dtOnJob
 if @@fetch_status <> 0 begin
  break
 end 


END
CLOSE curName
DEALLOCATE curName

Comments

No Comments

About Steve Gray

Steve is a seasoned (translate: old) developer in VB and ASP.NET. He spends most of his time in Dynamics GP, writing custom mods for consulting firms. Crystal reports, eConnect, VS Tools for Dynamics... anything that comes along.