Whenever we want to loop something we always look for logic like WHILE LOOP or FOR LOOP. Trust me on my word that both of them are cursor when it is about SQL Server.
It is commonly believed that the cursor is Database Objects. I have always given the definition of it as they are database objects used to manipulate data in a set on a row-by-row basis.
Just a few days ago – Imran one of the active readers of the blog asked me question if the cursor is database object or datatype? My answer to this question is it is Database Object. However, this question is very, very interesting. We define cursor same was as datatypes using DECLARE statement and it can be used the same way as any other data types.
I would like to see all of your opinions about what do you think about the this subject? Database Object or Database Datatype.
Here are few of the blog posts which are very much related to the subject. I would like all of you to check that out..
Please leave a comment with your thought. I will be happy to discuss with you more on this topic.
Reference: Pinal Dave (https://blog.sqlauthority.com)
34 Comments. Leave new
CURSOR is an object.
I think cursor is an database object, fetch the row by row record.
Cursor is an object
what is advantage of using cursor
Sir I am MCA student i want to know difference between View and Cursor….
cursor is not a data type if it is data type then it should be in sys.types for that we can say cursor is an object of db,
Cursor is a database object but we can’t use dbo with it and it gives error.Can anyone tell me why this is so?
we can say cursor as database code not a database object.database objects are tables,indexes,views.database code like stored procs,cursors
It is a data type. Please see the statement from Technet “All data stored in Microsoft SQL Server must be compatible with one of these base data types. The cursor data type is the only system data type that cannot be assigned to a table column. It can be used only with variables and stored procedure parameters.”
https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/ms187594(v=sql.105)
If its an object then it should be visible in object explorer. But we do not see the cursor there. Anything which is declared should be a Variable. I think its a variables which takes datatype of a result set.
what is performance tunning in sql in what all the concepts we use performance tunning?