Reputation: 478
I'm having a problem with regards in sorting inside the View on SQL Server 2008. Please refer to the Image below.
as you can see in the designer, i've sort the Column SeqID (Int Datatype), but when i select the View, the the Sorted Column seems not working.
Any suggestions?
Upvotes: 0
Views: 263
Reputation: 10853
Why do you need to sort a view? A view is like a table so you sort it when you select from it:
select * from V_APDoc order by SeqID DESC;
Upvotes: 3
Reputation: 166476
From CREATE VIEW (Transact-SQL)
The ORDER BY clause is used only to determine the rows that are returned by the TOP or OFFSET clause in the view definition. The ORDER BY clause does not guarantee ordered results when the view is queried, unless ORDER BY is also specified in the query itself.
From the quote, you should always specifiy the SORT ORDER if you wish to guarantee the ordered results.
Upvotes: 1