C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Using ORDER BY clause in the definition of a view


Posted Date: 11 Mar 2004    Resource Type: Articles    Category: Databases
Author: Satheesh SugumaranMember Level: Gold    
Rating: Points: 7



Normaly if we use ORDER BY clause in a view we'll get the following error

Error : The ORDER BY clause is invalid in views, inline functions, derived tables, and subqueries, unless TOP is also specified.


Inspite of this if we want to use ORDER BY clause in a view, consider using the following method

USE pubs
GO

CREATE VIEW AuthorsByName
AS
SELECT TOP 100 * FROM authors
ORDER BY City
GO


The TOP construct is most useful when you combine it with the ORDER BY clause. The only time that SQL Server supports an ORDER BY clause in a view is when it's used in conjunction with the TOP keyword.





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Missing field in subquery doesn't raise any error
Previous Resource: Calculate the product of a field
Return to Discussion Resource Index
Post New Resource
Category: Databases


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use