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
 Creating Views

Author  Topic 

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2008-08-27 : 07:43:44
When I tried to create view using this statement:

SELECT id, int1, date1
FROM sprintcalibrationrequest
UNION ALL
SELECT id, int2, date2
FROM sprintcalibrationrequest
UNION ALL
SELECT id, int3, date3
FROM sprintcalibrationrequest
ORDER BY id DESC


I'm getting a message:
The ORDER BY clause is invalid in views, inline functions, derived tables, unless TOP is also specified.

What's the problem?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-27 : 07:46:13
as suggested you need TOP clause if you want to use ORDER BY. In fact you dont need ORDER BY in your view at all. just use ORDER BY only while retrieveing data from it like

SELECT * from View ORDER BY field
Go to Top of Page
   

- Advertisement -