It is commonly believed that cursor are Database Objects. I have always given the definition of cursor as SQL Server cursors 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 reader of blog asked me question if cursor is database object or datatype? My answer to this question is Cursor 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 same way as any other datatypes.
I would like to see all of your opinion about what do you think about cursor? Database Object or Database Datatype.
Reference : Pinal Dave (http://blog.SQLAuthority.com)




hi ,sir
i have a table named leave having field like leavetype, from, to,
noofhours
how can i retrive the row by row wise inorder to calculate the noofhours
ie
these are the data of noofhours field
10.50 (it equals 10 hours n 30 min)
20.50
12.25
i want to get the each row n split the 10.50 value to two
ie. 10 n 50 n make a calculation like 50*100/60
ie i want to make the 50 into clock time
after each calculations i want to add all the data
n return the result
how can i do this …………
can u pls help me
can anyone help me about this????
hi ammen
can u plz try this ?
select leavetype,(abs(substring(loofhours,4,5))*100/60) as totalnoofhours from tablename order by totalnoofhours asc;
I think Cursor is a System DataType not Databse Object.
We create Cursor type Varaibles
I too accept the view of Vivek
[...] Deallocate cursor (Read More Here) [...]
I think it’s a database object. Although we define it like a variable, it can contain all the data of all columns retrieved per row and move it into other variables. This can be any datatype!!
So in my mind, it’s a database object and not a datatype (contains more information, and from all different datatypes)
hello sir,
first of all i want to give u my answer of question “Is Cursor Database Object or Datatype ”
i think cursor is a datatype not object because the definition and declaration type is same as other datatype.
now i have a question , i m writing a stored procedure using cursor.
set @test_temp_query_one = ‘ SET
@test_temp_count_one = CURSOR FORWARD_ONLY
STATIC FOR SELECT MAX(FLID) FROM ( SELECT TOP ‘ +
cast(@VAR_DIVIDE2 as varchar(50)) + ‘ FLID FROM ‘+
cast(@var_table as varchar(50)) +’ WHERE (FLFILENO
!=’ + cast(@VAR_SLIP_NO as varchar(50)) +’) ORDER BY
FLID ) FLID ; OPEN @test_temp_count_one ‘
EXEC sp_executesql @test_temp_query_one , N’
@test_temp_count_one CURSOR OUTPUT’,
@test_temp_count_one OUTPUT
FETCH NEXT FROM @test_temp_count_one INTO @VAR_FILE_RANGE2
this is a part of the proceduer because it’s so long…
when i am executing this procedure the i got an error
“Operand type clash: nvarchar is incompatible with cursor”
this pro executing with c#.net pro .
now my question is……
tell me the list of datatype , those incompatible with cursor in sql server 7.0
tahnks in advance