x
login about faq Site discussion (meta-askssc)

What is a #Cursor

Seeder question

This is a Regular Cursor

Declare MyCursor cursor for
Select Id, Name 
From Customer

This is a #Cursor

Declare #MyCursor cursor for
Select Id, Name 
From Customer

Questions:

  1. What is the difference?
    • Is one preferred over the other?
    • Is it the same difference as in a TABLE and a #TABLE?
more ▼

asked Mar 19 '10 at 03:38 PM in Default

Raj More gravatar image

Raj More
1.7k 74 78 82

+1 - nice seeder q

Mar 19 '10 at 04:11 PM Matt Whitfield ♦♦

Excellent question.

Mar 19 '10 at 04:31 PM Grant Fritchey ♦♦

Nice question. Not sure I know that this is anything more than a naming convention. I typically declare cursors with an @ symbol. In the rare occasion that I use a cursor.

Mar 19 '10 at 07:10 PM CirqueDeSQLeil
(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

I believe the origin of this goes back to Pandora. When she opened the box, the ills and mischief of man and all that is evil spilled out, leaving only one thing left in the box--that thing was not a cursor...

more ▼

answered Mar 19 '10 at 09:10 PM

Scot Hauder gravatar image

Scot Hauder
5.7k 13 15 18

Awesome answer.

Mar 20 '10 at 01:56 AM TimothyAWiseman

+1 - epic suggestion, off to update wikipedia's Pandora's Box entry ...

Mar 20 '10 at 07:41 AM Fatherjack ♦♦
(comments are locked)
10|1200 characters needed characters left

I believe this just to be a naming convention and a matter of preference. If I use a cursor I use the following:

Declare @MyCursor cursor for
Select Id, Name 
From Customer
more ▼

answered Mar 19 '10 at 07:13 PM

CirqueDeSQLeil gravatar image

CirqueDeSQLeil
3.9k 6 11 15

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x914
x54
x27

asked: Mar 19 '10 at 03:38 PM

Seen: 1006 times

Last Updated: Mar 26 '10 at 02:51 PM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.