Link to home
Start Free TrialLog in
Avatar of batchakamal
batchakamalFlag for India

asked on

Microsoft, SQL Server, 2005, view with order by clause

Hi,
I have crated a view with Top 100 Percent in the Select Clause and an order by Column name. It is working fine when I execute the view in the Enterprise Manager.

But When I put,

Select * from View1

It is not giving the sorted result.
Avatar of imitchie
imitchie
Flag of New Zealand image

this works right?
Select * from View1 order by columnname
i think top 100% order by x simply tells it to collect: up to 100%, by order of column x.  it can do that using multiple threads and arrive at some result. but because it's a view, it's the the final result. the result gets dumped in any order (that threads complete)
Avatar of Guy Hengel [angelIII / a3]
in views, you need to use the following method to allow sortings:


CREATE VIEW view_name 
AS 
SELECT TOP 100 PERCENT ... 
FROM ... 
WHERE ... 
ORDER BY ...

Open in new window

sorry, I notice you did that :(

how many CPU does your server have?
Check whether there exists another view with the same name and different owner  ?
Avatar of batchakamal

ASKER

We have Only one processor
If I put

Select * From View1 Order By Column2

It is working fine. But I require it to sort when I select.
There is only one view with that name.
ASKER CERTIFIED SOLUTION
Avatar of imitchie
imitchie
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It Works out. But I would like to know whether this will affect our performance or not.