---
title: "What is Cursor in SQL Server?"  
description: "A Cursor is a database object that represents a result set and is used to manipulate data row by row. When a cursor is opened, it is positioned on a r"  
author: "Uttam Misra"  
published: 2011-03-03  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/124/what-is-cursor-in-sql-server  
category: "database"  
tags: ["database"]  
reading_time: 1 minute  

---

# What is Cursor in SQL Server?

InSQL procedures, a [cursor](https://www.mindstick.com/articles/13003/create-a-simple-cursor-in-sql-server) makes it possible to [define](https://yourviews.mindstick.com/audio/1110/lifestyles-choices-that-define-our-lives) a [result](https://www.mindstick.com/blog/12011/advantages-of-getting-result-oriented-seo-from-an-agency) set (a set of data rows) and performs [complex](https://yourviews.mindstick.com/audio/1142/understanding-the-complex-factors-influencing-mental-health) logic on a row by row basis. By using the same mechanics, an [SQL procedure](https://www.mindstick.com/blog/304484/explain-the-sql-stored-procedures) can also define a result set and return it directly to the caller of the SQL procedure or to a [client](https://www.mindstick.com/articles/12905/fynsis-announce-suitecrm-customer-portal-independent-client-service-platform) application.

A cursor can be viewed as a [pointer](https://www.mindstick.com/articles/11/pointers) to one row in a set of rows. The cursor can only [reference](https://www.mindstick.com/forum/774/reference-what-does-this-error-mean-in-php) one row at a time but can move to other rows of the result set as needed.

##### To use cursors in SQL procedures, you need to do the following:

\

- Declares a cursor that defines a result set.
- Open the cursor to establish the result set.
- Fetch the data into local [variables](https://www.mindstick.com/articles/715/php-variables) as needed from the cursor, one row at a time.
- Close the cursor when done.

##### Please check this link for detailed information

https://www.mindstick.com/Articles/428/implementing-concept-of-cursor-in-sql-server

---

Original Source: https://www.mindstick.com/blog/124/what-is-cursor-in-sql-server

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
