SQL Server Cursor Reference (Syntax, etc)

2019-01-20 12:22发布

问题:

I don't use SQL Server Cursors often but when I do, I always have to look up the syntax and options.

So I wanted to ask, what is the best SQL Server Cursor reference on the web?.

I'm looking for a reference that explains all of the (major?) options (I.E. FAST_FORWARD) and also shows quick snippets of how to use it. (I.E. How to implement looping though a cursor and with a good practice for checking the @@FETCH_STATUS variable.)

Best Regards,
Frank

Quick Update: I'm looking for a balance of quick-reference but detailed enough to see my options. As an example. MSDN is a great reference guide but it has too much detail. The reference, ideally, should be concise.

Further update: I'm still looking for sources. If someone posts a good source that fits my criteria of concise, I will accept that answer...

回答1:

I'd start out with the MSDN help page for cursors...

http://msdn.microsoft.com/en-us/library/ms180169.aspx



回答2:

How to Perform SQL Server Row-by-Row Operations Without Cursors:
http://www.sql-server-performance.com/articles/per/operations_no_cursors_p1.aspx

SQL Server Cursor Examples (with Cursor Alternatives):
http://www.mssqltips.com/tip.asp?tip=1599



回答3:

I always use the built in "Transact-SQL Reference" help within management studio. I find the examples on everything there to be more than enough for what I need.