Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

ORDER BY in a cursor Expand / Collapse
Author
Message
Posted Tuesday, July 9, 2013 3:22 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 9:59 AM
Points: 44,609, Visits: 42,349
Please note: 5 year old thread.


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1471496
Posted Tuesday, July 9, 2013 6:15 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 3:57 PM
Points: 1,751, Visits: 2,507
Just because it is old doesn't mean some of us won't find it to be useful information.

The Redneck DBA
Post #1471574
Posted Tuesday, July 9, 2013 6:29 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 9:59 AM
Points: 44,609, Visits: 42,349
Never said it would. Hopefully however it will prevent people wasting time trying to solve a problem that's been solved for 5 years (as I did this morning before I noticed the date)


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1471580
Posted Tuesday, July 9, 2013 10:25 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, November 23, 2014 3:10 AM
Points: 3, Visits: 29
Guys

It saved me lots of time after a wasted afternoon. So, it's an oldie but goldie!

P.
Post #1471940
Posted Wednesday, July 10, 2013 3:35 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: 2 days ago @ 7:41 AM
Points: 1,142, Visits: 3,406
Jason Shadonix (7/9/2013)
Just because it is old doesn't mean some of us won't find it to be useful information.

Glad the thread helped you, but it is not necessary to say thanks 5 years after the fact.




The SQL Guy @ blogspot

@SeanPearceSQL

About Me
Post #1472023
Posted Friday, February 21, 2014 3:24 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, February 21, 2014 3:21 PM
Points: 3, Visits: 7
Selecting into a temp table first is not a solution. When your cursor selects the data back out of the temp table, there's no guarantee it will be in the same order. Sort Order when SELECT FROM Table Variables Unless that's untrue, you should take that suggestion down since many may not read past it.
Post #1544203
Posted Tuesday, November 24, 2015 9:32 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, December 22, 2015 12:53 PM
Points: 2, Visits: 112
Good morning,

Just to ADD, I saw that adding

DECLARE x_cursor CURSOR STATIC READ_ONLY FOR ...

Solves the issue

best regards :)
Post #1739728
Posted Wednesday, November 25, 2015 11:00 AM


Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Saturday, March 19, 2016 1:53 AM
Points: 776, Visits: 1,556
rjuarez71 (11/24/2015)
Good morning,

Just to ADD, I saw that adding

DECLARE x_cursor CURSOR STATIC READ_ONLY FOR ...

Solves the issue

best regards :)


From MSDN,
"STATIC
Defines a cursor that makes a temporary copy of the data to be used by the cursor. All requests to the cursor are answered from this temporary table in tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications."

That may not be what the user originally wanted. The goal is to display the results of the fetches in the order indicated in the SELECT. I played with the original solution provided and it works fine on my end.
Post #1740139
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse