判断版本,然后执行
-- select serverproperty('productversion'),serverproperty('productlevel'),serverproperty('edition'), @@VERSION
--SQL2000:8.00.194 RTM Personal Edition Microsoft SQL Server 2000 - 8.00.194 (Intel X86) Aug 6 2000 00:57:48 Copyright (c) 1988-2000 Microsoft Corporation Personal Edition on Windows NT 6.2 (Build 9200: )
--SQL2008:10.50.1600.1 RTM Enterprise Edition (64-bit) Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64) Apr 2 2010 15:48:46 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: )
--SQL2012:11.0.3000.0 SP1 Enterprise Edition (64-bit) Microsoft SQL Server 2012 (SP1) - 11.0.3000.0 (X64) Oct 19 2012 13:38:57 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
-- select CONVERT(numeric(20,2), LEFT(CONVERT(varchar,serverproperty('productversion')),CHARINDEX('.',CONVERT(varchar,serverproperty('productversion')),0)))
--SQL2000
select top 20 * from ShouFeiList where 1=1 and (1<>0) and ( nID not in ( select top 15000 nID from ShouFeiList where 1<>0 order by nID)) order by nID
--SQL2008
SELECT* FROM(SELECT *, ROW_NUMBER () OVER (ORDER BY nID) AS rowNumber FROM ShouFeiList where 1<>0) as T WHERE rowNumber BETWEEN 15000 and 15020
--SQL2012
select * from ShouFeiList Order by nID Offset 15000 Row Fetch Next 20 Rows Only