Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 In which order the output is coming...plz help

Author  Topic 

Amjath
Yak Posting Veteran

66 Posts

Posted - 2010-07-23 : 00:24:45
I have a problem, depends on the selecting items, my display order got changed. the case where im facing problem

SELECT a1,b1 FROM Table1
WHEREb1 IN (86429, 134486, 49816)

SELECT a1,b1,c1,d1 FROM Table1
WHERE b1 IN (86429, 134486, 49816)

SELECT b1,a1,c1 FROM Table1
WHERE b1 IN (86429, 134486, 49816)

All these above mention query give same output, but the order is different.

I have following Index on my table
1)d1, c1
2)c1, b1
3)b1

Moreover a1 is a primary key.

moreover, plz let me know how data will be displayed if i didnt specify any order by field.

with thanks & regards
Amjath

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-07-23 : 00:33:21
without specifying the ORDER BY clause, the sequence of the records return is random / non-deterministic. There is no guarantee it will return in the same sequence every time you execute the query


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Amjath
Yak Posting Veteran

66 Posts

Posted - 2010-07-23 : 00:37:39
So it means, chances of getting different sequence of record for the same query.
Thanks a lot
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-07-23 : 04:40:19
Yup. If you need a specific order, specify the appropriate ORDER BY

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -