比如
Create Function test()
returns table
as
return
select * from t
order by t1这样为什么编译不通过,(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.)
为什么这里不能用order by?

解决方案 »

  1.   

    Create Function test()
    returns table
    as
    return
    select top 100 percent * from t
    order by t1
      

  2.   

    除非同时指定了 TOP,否则 ORDER BY 子句在视图、内嵌函数、派生表和子查询中无效。
      

  3.   

    学习,原来可以这样用top 100 percent ,谢谢
      

  4.   

    好像还是不行,select top 100 percent * from t
    order by t1是可以排序,但是到外面select * from test()出来的结果集还是没有排序,
    求教为什么?