Home
Manage Your Code
Snippet: cursor declare template (SQL)
Title: cursor declare template Language: SQL
Description: cursor declare template Views: 59
Author: Jason Huo Date Added: 12/3/2008
Copy Code  
DECLARE @Parameter1 sqltype
DECLARE @Parameter2 sqltype
-- other parameter ...
DECLARE Cursor_Name CURSOR FOR 

SELECT statement
OPEN Approver_Cursor

FETCH NEXT FROM Cursor_Name
INTO @Parameter1, @Parameter2  -- ,other parameter 

WHILE @@FETCH_STATUS = 0
BEGIN
   
   -- process code

   FETCH NEXT FROM Cursor_Name 
   INTO @Parameter1, @Parameter2 -- ,other parameter 
END

CLOSE Cursor_Name
DEALLOCATE Cursor_Name
Usage
just copy to the sql query anlyzer then replace parameters