their is a rule which i got to know before few days and i want to share with u that you cant use order by in functions....when u try to do so u will get this error..
sg 1033, Level 15, State 1, Procedure GetDataBaseDetail, Line 21
The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.
so to solve this problem you will have to use 'top ' ex.- top 1000 . with query where u want to use order by cluse.
Read More
sg 1033, Level 15, State 1, Procedure GetDataBaseDetail, Line 21
The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.
so to solve this problem you will have to use 'top ' ex.- top 1000 . with query where u want to use order by cluse.