Using Cursor – Basic syntax
October 26, 2007 at 12:29 pm | In SQL Server | Leave a CommentUsing Cursor – Basic syntax
DECLARE [cursor name] CURSOR
FOR
[SELECT query ]
OPEN [cursor name]
[DECLARE variables]
FETCH NEXT FROM [cursor name] INTO [variable list]
WHILE(@@FETCH_STATUS -1)
BEGIN
IF(@@FETCH_STATUS -2)
BEGIN
[Insert/Update statements]
END
FETCH NEXT FROM [cursor name] TO[variable list]
END
CLOSE [cursor name]
DEALLOCATE [cursor name]
No Comments Yet »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.