How To Execute the Cursor Queries with "OPEN" Statements?
Submitted by: AdministratorOnce a cursor is declared, you need to execute the query attached to the cursor so that the result set returned from the query can be accessed through the cursor. To execute the cursor query, you should use the OPEN statement as in this format:
OPEN cursor_name;
When you are done with using the result set attached to a cursor, you should close the result set to free up server resources.
The tutorial example below shows you how to open and close a cursor:
USE GlobalGuideLineDatabase;
GO
DECLARE ggl_cursor CURSOR FOR
SELECT * FROM ggl_links;
OPEN ggl_cursor;
-- result set is ready to use
-- other statements
CLOSE ggl_cursor;
DEALLOCATE ggl_cursor;
GO
Submitted by: Administrator
OPEN cursor_name;
When you are done with using the result set attached to a cursor, you should close the result set to free up server resources.
The tutorial example below shows you how to open and close a cursor:
USE GlobalGuideLineDatabase;
GO
DECLARE ggl_cursor CURSOR FOR
SELECT * FROM ggl_links;
OPEN ggl_cursor;
-- result set is ready to use
-- other statements
CLOSE ggl_cursor;
DEALLOCATE ggl_cursor;
GO
Submitted by: Administrator
Read Online MS SQL Server Job Interview Questions And Answers
Top MS SQL Server Questions
☺ | How To Execute the Cursor Queries with "OPEN" Statements? |
☺ | What Happens If Strings Are Casted into Wrong Code Pages in MS SQL Server? |
☺ | How To Convert a Numeric Expression from One Data Type to Another? |
☺ | How To Use Subqueries with the EXISTS Operators in MS SQL Server? |
☺ | How To Select All Columns of All Rows from a Table with a SELECT statement in MS SQL Server? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |
☺ | Sybase Interview Questions. |