question

Raj More avatar image
Raj More asked

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?
t-sqlcursorseeder-question
3 comments
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

+1 - nice seeder q
0 Likes 0 ·
Excellent question.
0 Likes 0 ·
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.
0 Likes 0 ·
Scot Hauder avatar image
Scot Hauder answered

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...

2 comments
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Awesome answer.
0 Likes 0 ·
+1 - epic suggestion, off to update wikipedia's Pandora's Box entry ...
0 Likes 0 ·
CirqueDeSQLeil avatar image
CirqueDeSQLeil answered

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
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.