Cursor in sql server

Posted by Sangeetha Mani under Sql Server on 12/14/2012 | Points: 10 | Views : 873 | Status : [Member] | Replies : 3
hi friends,

i have doubt while condition like while @@fetch_status
why we are using global variable there? what is the fetch_status ?

sangeetha.m


Responses

Posted by: Ranjeet_8 on: 12/14/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Look at this url
http://msdn.microsoft.com/en-us/library/ms187308.aspx

Sangeetha Mani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sandeepmhatre on: 12/15/2012 [Member] Starter | Points: 25

Up
0
Down
Details will be found here

http://sandeepmhatre.blogspot.in/2012/12/cursor-in-sql-server.html

Sandeep M,
Software Developer
Follow me on :
http://sandeepmhatre.blogspot.in

Sangeetha Mani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 12/15/2012 [Member] Silver | Points: 25

Up
0
Down

Hi Sangeetha,
In Cursor program, you take row by row to check data validate and then take action on them.
The fetch statement retrieves one row data (as per selection criteria in your statement) .
Before you go to check data you should first check whether the statement has retrieved any data or not ?
If yes then go inside the loop and take action else skip the body of loop.
@@FetchStatus =0 means successful execution of your statement.

Thanks,
Sanjay

Sangeetha Mani, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response