Collections:
"DECLARE ... CURSOR" - Declaring Cursor Objects in SQL Server
How To Declare a Cursor with "DECLARE ... CURSOR" in SQL Server Transact-SQL?
✍: FYIcenter.com
If you want to use a cursor to represent the result set of a query, you need to define a cursor name with a SELECT sub-statement using the "DECLARE ... CURSOR" statement using the following syntax format:
DECLARE cursor_name CURSOR FOR SELECT ...;
Note that the DECLARE statement will not actually execute the SELECT sub-statement. It only attaches the SELECT sub-statement to the cursor.
A cursor name should be deallocated to free up server resources if the cursor is not needed any more.
The tutorial example below shows you how to declare and deallocate a cursor.
USE FyiCenterData; GO DECLARE fyi_cursor CURSOR FOR SELECT * FROM fyi_links; -- other statements DEALLOCATE fyi_cursor; GO
⇒ "OPEN" - Executing the Query of a Cursor in SQL Server
⇐ What Are Cursors in SQL Server
2016-10-17, 3690🔥, 0💬
Popular Posts:
How To Recover a Dropped Index in Oracle? If you have the recycle bin feature turned on, dropped ind...
How To Format Time Zone in +/-hh:mm Format in SQL Server Transact-SQL? From the previous tutorial, y...
How To Concatenate Two Binary Strings Together in SQL Server Transact-SQL? SQL Server 2005 allows to...
What Are the Differences between BINARY and VARBINARY in MySQL? Both BINARY and VARBINARY are both b...
How To Get Year, Month and Day Out of DATETIME Values in SQL Server Transact-SQL? You can use DATEPA...