Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Declare or Create cursor

Status
Not open for further replies.

croiva25

Technical User
Dec 3, 2003
125
AU
Hi guys,I am quite new to sql 2000 and this question might be seen as a stupid one.
But I would like to know.Is DECLARE Cursor and CREATE Cursor the same thing, and if not what is the major difference?

Thanks
 
There is no syntax like create cursor i believe.
The syntax for cursor creation goes like

declare cursor cursorname for
Select statement
open cursorname
fetch next from cursorname
....

Youc an get tons of help from the Books online

I dont see any difference between create and declare cursor if not technical

Sugarthan

Sugarthan
 
Just remember that cursors are performance killers and should be used only VERY rarely. In most cases you can use a set-based statement to do what the cursor would do only much faster. Only use a cursor if you are calling a process that will only accept one record at a time. Usually the legitiamate uses of cursors are more onthe site admin side thatn the user interface side. I have never needed a cursor for any function done by the user interface. They are helpful for running some of the system stored procedures against a group of tables or fields.

Never ever use a cursor for an update, insert or delete. These can be done with set-based statements.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top