创建用到的表的SQL
CREATE TABLE [dbo].[emp_pay]( [employeeID] [int] NOT NULL, [base_pay] [money] NOT NULL, [commission] [decimal](2, 2) NOT NULL) ON [PRIMARY]
生成的表,及表中的数据:
--方法一select top 1 * from ( SELECT TOP 2 * FROM [dbo].[emp_pay] WHERE base_pay = 500 order by employeeID ASC) as a --注意:派生表后面一定要指定别名. order by a.employeeID DESC
--方法二select IDENTITY(int,1,1) ID,* INTO #Temp from [dbo].[emp_pay] where base_pay = 500 select * from #Temp where ID =2 drop Table #Temp
--方法三set rowcount 2SELECT * into #t from [dbo].[emp_pay] where base_pay = 500 set rowcount 1 delete from #t select * from #t set rowcount 0 drop table #t