|
INTERVIEW QUESTIONS
DATABASE
MS SQL SERVER
DETAILS
Question: How To Declare and Use Cursor Variables?
Answer: There are two ways to representing a cursor:
1. A cursor name - A static name representing a cursor object. A cursor name should be linked to a cursor object in the DECLARE statement.
2. A cursor variable name - A variable name pointing to a cursor object. A cursor variable name should be declared with the CURSOR data type. It should be then assigned with a cursor object using the SET statement.
The tutorial exercise below shows you how to declare a cursor variable and assign a cursor object to it:
USE GlobalGuideLineDatabase; GO
-- declare a cursor variable DECLARE @ggl_cursor CURSOR;
-- assign a cursor object SET @ggl_cursor = CURSOR FOR SELECT id, url, notes, counts, time FROM ggl_links;
|
|
|
Category |
MS SQL Server Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.3) By 8212 users |
Added on |
9/24/2014 |
Views |
68198 |
Rate it! |
|
|
Question:
How To Declare and Use Cursor Variables?
Answer:
There are two ways to representing a cursor:
1. A cursor name - A static name representing a cursor object. A cursor name should be linked to a cursor object in the DECLARE statement.
2. A cursor variable name - A variable name pointing to a cursor object. A cursor variable name should be declared with the CURSOR data type. It should be then assigned with a cursor object using the SET statement.
The tutorial exercise below shows you how to declare a cursor variable and assign a cursor object to it:
USE GlobalGuideLineDatabase; GO
-- declare a cursor variable DECLARE @ggl_cursor CURSOR;
-- assign a cursor object SET @ggl_cursor = CURSOR FOR SELECT id, url, notes, counts, time FROM ggl_links; Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
How To Loop through the Result Set with @@FETCH_STATUS?
|
View Answer
|
|
How To Transfer Data from a Cursor to Variables with a "FETCH" Statement?
|
View Answer
|
|
How To Fetch the Next Row from a Cursor with a "FETCH" Statement?
|
View Answer
|
|
How To Execute the Cursor Queries with "OPEN" Statements?
|
View Answer
|
|
How To Declare a Cursor with "DECLARE ... CURSOR" in MS SQL Server?
|
View Answer
|
|
What Are Cursors in MS SQL Server?
|
View Answer
|
|
Can You Create a Logon Trigger in SQL Server 2005 Express Edition?
|
View Answer
|
|
Can You Roll Back the DDL Statement in a Trigger?
|
View Answer
|
|
How To Create a DDL Trigger using "CREATE TRIGGER" Statements?
|
View Answer
|
|
How To Override DML Statements with Triggers?
|
View Answer
|
|
What Happens to a Trigger with Multiple Affected Rows?
|
View Answer
|
|
How To Access the Deleted Record of an Event?
|
View Answer
|
|
How To Access the Inserted Record of an Event?
|
View Answer
|
|
How To See the Event List of an Existing Trigger using sys.trigger_events?
|
View Answer
|
|
How To Create a Trigger for INSERT Only?
|
View Answer
|
|
How To Disable Triggers using "DISABLE TRIGGER"?
|
View Answer
|
|
How To Get the Definition of a Trigger Back?
|
View Answer
|
|
How To Delete Existing Triggers using "DROP TRIGGER"?
|
View Answer
|
|
How To Modify Existing Triggers using "ALTER TRIGGER"?
|
View Answer
|
|
How To List All Triggers in the Database with sys.triggers in MS SQL Server?
|
View Answer
|