What are cursors in SQL Server?

What are cursors in SQL Server?

- Cursors allow row-by-row processing of the resultsets.

- It is a database object which is used to retrieve data from a resultset one row at a time.

Following are the types of cursors:

1. Static
2. Dynamic
3. Forward-only
4. Keyset-driven.

- Each time you fetch a row from the cursor, it results in a network roundtrip.

- Cursors are also costly because they require more resources and temporary storage.

Syntax:
DECLARE CURSOR CURSOR_NAME

Example:
DECLARE CURSOR empId_cur
What is a join and explain types of joins
Joins are used in queries to explain how different tables are related.......
What is an extended stored procedure in SQL Server?
An extended stored procedure compiles as DLL and are created to expand capabilties of user defined stored procedure.......
What are triggers in SQL Server?
Triggers are special kind of event driven stored procedures. Executed automatically when an INSERT, UPDATE or DELETE operation takes place on a table.......
Post your comment