Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Cursor Expand / Collapse
Author
Message
Posted Tuesday, June 9, 2009 1:17 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, October 22, 2010 5:29 AM
Points: 2,353, 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
Post #731195
Posted Tuesday, June 9, 2009 2:22 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 2:44 AM
Points: 5,018, Visits: 10,532
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

Get your two-cent-answer quickly
spaghettidba.com
@spaghettidba
Post #731224
Posted Tuesday, June 9, 2009 4:56 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, October 22, 2010 5:29 AM
Points: 2,353, Visits: 94
Hi

Thanks For reply. i will See that link

Regards
Guru.K
Post #731311
Posted Tuesday, June 9, 2009 5:14 AM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Thursday, August 21, 2014 3:52 PM
Points: 5,988, Visits: 12,923
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.


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

Post #731317
Posted Thursday, June 11, 2009 10:36 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, July 17, 2014 12:08 PM
Points: 136, Visits: 633
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
Post #733206
Posted Friday, June 26, 2009 12:39 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 6:43 AM
Points: 23,270, Visits: 31,986
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)?




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)
Post #742398
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse