Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 FUNCTIONALITY OF CURSOR IN SQL SERVER 2008

Author  Topic 

kond.mohan
Posting Yak Master

213 Posts

Posted - 2012-01-12 : 09:20:09

Hi

can anybody explain the functionality of cursor

and how to COMPILE THE CURSOR AND
how to EXECUTE THE CURSOR
And execution process of cursor within the stored procedure


and what is the main scope of the cusor

with simple example

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-01-12 : 09:42:06
A cursor gives you the possibility to work on records one by one of a recordset given by a SELECT.
This is very slow.
Main scope is: used by people who don't know how to think set based.

In my beginnings of T-SQL I didn't know the GROUP BY and I came from COBOL so I used a cursor to make my own GROUP BY.
Sounds funny but it is the truth.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2012-01-12 : 10:29:53
quote:

In my beginnings of T-SQL I didn't know the GROUP BY and I came from COBOL so I used a cursor to make my own GROUP BY.
Sounds funny but it is the truth.


wow. Did that go into production code?
(I'm not mocking you by the way, I actually think that's kind of awesome)

Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-01-12 : 10:38:21
quote:
Originally posted by Transact Charlie

quote:

In my beginnings of T-SQL I didn't know the GROUP BY and I came from COBOL so I used a cursor to make my own GROUP BY.
Sounds funny but it is the truth.


wow. Did that go into production code?
(I'm not mocking you by the way, I actually think that's kind of awesome)

Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION



Yes in production as a step in a DTS package.
Replaced in the year 2010...prior to that there was no need to change anything


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-12 : 10:56:48
quote:
Originally posted by webfred

A cursor gives you the possibility to work on records one by one of a recordset given by a SELECT.
This is very slow.
Main scope is: used by people who don't know how to think set based.

In my beginnings of T-SQL I didn't know the GROUP BY and I came from COBOL so I used a cursor to make my own GROUP BY.
Sounds funny but it is the truth.


No, you're never too old to Yak'n'Roll if you're too young to die.




COBOL?????


O/S 390???



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-01-12 : 13:26:56
HP 3000 MPE


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -