SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Cursor


Cursor

Author
Message
gururajan
gururajan
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2375 Visits: 94
Hi friends
I want use Cursors in my query. How to use the cursors in sql2000. i want to some eample with any other link for the breif explenation.


Regards
Guru.K
Gianluca Sartori
Gianluca Sartori
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23489 Visits: 13362
Your primary source is BOL (Books OnLine).

http://msdn.microsoft.com/en-us/library/bb418471(SQL.10).aspx

Did you try google?

http://www.google.it/search?q=sql+server+2000+cursors

Regards
Gianluca

--Gianluca Sartori

How to post T-SQL questions
spaghettidba.com
@spaghettidba
gururajan
gururajan
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2375 Visits: 94
Hi

Thanks For reply. i will See that link

Regards
Guru.K:-)
george sibbald
george sibbald
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24136 Visits: 13698
I might as well be first to ask, WHY do you want to use cursors as opposed to set based.?

The heavy hitters should be descending en masse on this at some point, Jeff?

Unless possibly your query is for database administration purposes there is bound to be a better way than cursors to do it, so describe your problem.

---------------------------------------------------------------------
myheadhurts
myheadhurts
Old Hand
Old Hand (368 reputation)Old Hand (368 reputation)Old Hand (368 reputation)Old Hand (368 reputation)Old Hand (368 reputation)Old Hand (368 reputation)Old Hand (368 reputation)Old Hand (368 reputation)

Group: General Forum Members
Points: 368 Visits: 635
Here's a template for a generic cursor. See BOL for details.

-----------------------------------------------------------

-- to reduce traffic don't bother with display of row count
set nocount on

-- define the cursor --
declare @object varchar(128)
declare mycursor scroll cursor
for
-- the SQL --
select SomeData from SomeTable

-- traverse the cursor --
open mycursor
fetch first from mycursor into @object
while @@fetch_status <> -1
begin
if @@fetch_status <> -2
begin
-- do the work here --
print @object
end
fetch next from mycursor into @object
end

-- clean up --
close mycursor
deallocate mycursor




-MarkO

"You do not really understand something until you can explain it to your grandmother" - Albert Einstein
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)

Group: General Forum Members
Points: 93147 Visits: 38955
gururajan (6/9/2009)
Hi friends
I want use Cursors in my query. How to use the cursors in sql2000. i want to some eample with any other link for the breif explenation.


Regards
Guru.K


You haven't answered the most important question asked. WHY do you want to use cursors? Set-based operations are much more efficient than cursors, and to use an illistration provided by one of our top gurus:

If you want to cook some rice, do you put them in the pot one at a time in one big cup (Paraphrased a bit)?

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search