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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Variable vs Values

Status
Not open for further replies.

PMR191061

Programmer
Nov 2, 2005
1
GB
I have two identical select statements. One uses Variables and the other uses actual hard coded values but for some reason they return data in a different order.

please can you help me?
 

If you want a specific order, then use the ORDER BY clause. Without specifying an ORDER BY, the DBMS is free to return the records in any order it wants.

 
Also look at your query execution plan, is it the same for both?

“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top