是否有符合ANSI SQL的SQL SERVER版本SELECT TOP n?
SELECT TOP n
ANSI / ISO SQL:2003引入了 窗口函数 :
SELECT * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY age ASC) AS rownum, person_id, person_name, age FROM person ) AS foo WHERE rownum <= 3
自SQL Server 2005起,Microsoft SQL Server就支持此语法。http: //msdn.microsoft.com/zh- cn/library/ms189798(v=sql.90).aspx
ANSI / ISO SQL:2008为引入了一种更简单的语法FETCH FIRST,该语法可能更类似于Microsoft / SybaseTOP语法:
FETCH FIRST
TOP
SELECT person_id, person_name, age FROM person FETCH FIRST 3 ROWS ONLY
Microsoft尚不支持此语法。另请参见http://en.wikipedia.org/wiki/Select_(SQL)#Limiting_result_rows