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)
 View?

Author  Topic 

DeepakNewton
Starting Member

39 Posts

Posted - 2007-07-16 : 02:20:22
I have a view where in i need to sort by lastname , could any plz go thru below statement and let me know this Statement the optimized one because i used TOP 100 Percent i do no whether it will cause performance in the view, since i cant directly access Table. only to sort by lastname i used TOP 100 percent

Create view vwEmp AS
SELECT
TOP 100 Percent
EmpAccNo
, FirstName
, LastName
, DeptNo
FROM
tblZAEmployee EM
INNER JOIN
tblZADepartment DP
ON
DP.deptNo=EM.deptno

ORDER BY
LastName
ASC

Thanks
Deepak

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-07-16 : 04:45:23
Why dont you create a view without Order by and use order by when selecting data from it?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2007-07-16 : 20:49:59
ORDER BY in a view is meaningless. You have to do it on the select. This is especially true if
a) You join to the view
b) You move up to SQL Server 2005 where this side effect has been optimised out.
Go to Top of Page
   

- Advertisement -