June 9, 2009 at 1:17 am
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
June 9, 2009 at 2:22 am
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
June 9, 2009 at 4:56 am
Hi
Thanks For reply. i will See that link
Regards
Guru.K:-)
June 9, 2009 at 5:14 am
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.
---------------------------------------------------------------------
June 11, 2009 at 10:36 am
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
June 26, 2009 at 12:39 am
gururajan (6/9/2009)
Hi friendsI 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)?
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply