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
 General SQL Server Forums
 New to SQL Server Programming
 Ordering in a View

Author  Topic 

CleverRainbow
Starting Member

3 Posts

Posted - 2012-06-01 : 23:21:44
Basically i'm trying to insert an order by function into a view, but this can only be done using TOP. What I have at the moment does not order anything, however; if I change "top 100 percent" to "top 99.9 percent" it will order only the 'Fname' and leave 'Lname' unordered.

USE dbo.
GO
CREATE VIEW wwOverdueVideos AS
SELECT TOP 100 PERCENT Fname, Lname
FROM Member
ORDER BY Fname, Lname ASC
GO

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-01 : 23:37:28
there's no use in giving ORDER BY inside view as it will not guarantee order of returning resultset. For that you need to give order by in select statement which retrives details from the view like

SELECT * FROM wwOverdueVideos ORDER BY Fname, Lname ASC


see

http://visakhm.blogspot.com/2010/01/behaviour-of-order-by-inside-view.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -