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 2005 Forums
 Transact-SQL (2005)
 sort order

Author  Topic 

paruchuris
Starting Member

2 Posts

Posted - 2009-02-25 : 05:09:09
Hi,
When I am executing the following query the data is coming in one sort order.
In this case iam getting the data for "Activitynm = 20 and 30" values.
(select
ACTYHDRID,
ACTIVITYHEADERNAME,
ACTIVITYNM,
FULLNM,
ADJSTARTDTM AS ADJSTARTDTM,
ADJENDDTM AS ADJENDDTM,
STDQTY,
COMPLETEDQTY,
SCRAPPEDQTY,
ALLOCATEDHRSQTY,
STDHOURSQTY
from
vp_wfarepactyevent
where
ACTIVITYHEADERNAME = '682861')

the same query except in the where clause I am changing the selection criteria to get the "Activitynm = 20" then the sort order is different. The query is as follows.
select
ACTYHDRID,
ACTIVITYHEADERNAME,
ACTIVITYNM,
FULLNM,
ADJSTARTDTM AS ADJSTARTDTM,
ADJENDDTM AS ADJENDDTM,
STDQTY,
COMPLETEDQTY,
SCRAPPEDQTY,
ALLOCATEDHRSQTY,
STDHOURSQTY
from
vp_wfarepactyevent
where
ACTIVITYHEADERNAME = '682861'
AND activitynm = 20
Does any one have any idea what might influence the sort order.
Regards,
SP

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-02-25 : 06:25:00
Have an "order by" clause if you want it sorted. There is no sort order without "order by" clause.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-25 : 09:45:26
i'm guessing vp_wfarepactyevent is a view. even if there's order by inside view definition, you cant guarantee the order of retrieval unless you use order by in select query


Go to Top of Page
   

- Advertisement -