查询N-M条记录。
select IDENTITY(int,1,1) as iid,* into #temptable from yourtable
select top M-N * from #temptable where iid>=NOR:select top M-N * from yourTable where id not in(select top N-1 id from table)
ID为表具有唯一值的任何字段
select IDENTITY(int,1,1) as iid,* into #temptable from yourtable
select top M-N * from #temptable where iid>=NOR:select top M-N * from yourTable where id not in(select top N-1 id from table)
ID为表具有唯一值的任何字段
解决方案 »
- sql server连接问题
- 问个问题,sql中,一个表中的某个字段在数据库中为数字,我想在显示的时候转换为文字,比如字段中一个值为7或者3,我想搜索后,如果值是7
- .dat用记事本打开是乱码。应用什么来打开。里面放的是数据。。。
- 很急的问题,用SQL计算当月的天数
- 面试题目,小绵羊过来看一下。
- 进行dbcc checkdb()时可不可以强制关闭sql server
- 急:SQL Server子查询很慢,求教
- 关于msdaora.dll加载到64位机器上的问题
- 关于SqlServer2005复制订阅性能的一个问题
- 求助!在數據存入數據表的時候,也同時存入另一個數據表的問題。
- 简单问题,请您回答!
- 怎样将表中的数据通过PSTN或DDN导入远程数据库服务器?
select top M-N * from #temptable where iid>=N
select top m-n * from #temp where F0>=n
1) select * from (select top 50 * from table order by id) a where id not in (select top 29 id from table order by id)2) select top 20 * from #temp where id not in (select top 29 id from #temp)
一次将所有的记录返回前台
网络资源/几服务器资源站用太大
set @SQLStr='SELECT Top '+cast(@每页大小 as varchar)+' * FROM 表 WHERE 主键列 NOT IN (SELECT TOP '+cast(@每页大小*@第几页 as varchar)+' 主键列 from 表 )'
exec(@SQLStr)
select top (20-10) * from tableName where 关键字段 not in (select top 10 关键字段 from tableName)2.
select top (20-10+1) * from (select top 20 * from tableName order by 关键字段 desc) order by 关键字段
用存储过程实现的分页程序
*/
CREATE procedure Department_pagination
@SelectStr nvarchar(1000),
@ColumnStr nvarchar (1000),
@OrderStr nvarchar (1000),
@CurrentPage int,
@PageCount int
as
declare @TimeName nvarchar(25)
declare @TableStr nvarchar(1000)select @TimeName = convert(nvarchar(23), getdate(), 121)
set @TimeName = REPLACE(@TimeName, '.', '')
set @TimeName = REPLACE(@TimeName, ':', '')
set @TimeName = REPLACE(@TimeName, '-', '')
set @TimeName = REPLACE(@TimeName, ' ', '')select @TableStr='create table ##Tab' + @TimeName + '(wb int identity,'
exec(@TableStr+@ColumnStr+')')
exec('insert into ##Tab' + @TimeName + ' ' + @SelectStr + ' order by ' + @OrderStr)
exec('select * from ##Tab' + @TimeName + ' where wb between ((' + @CurrentPage + '-1)*' + @PageCount + '+1) and ' + @CurrentPage + '*' + @PageCount + ' order by wb')
exec('drop table ##Tab' + @TimeName)
GO参数1:select语句。2:字段列表。3:排序字段。4:当前页。5每页数目
@lastProductID int,
@pageSize int
AS
SET ROWCOUNT @pageSize
SELECT *
FROM Products
WHERE [standard search criteria]
AND ProductID > @lastProductID
ORDER BY [Criteria that leaves ProductID monotonically increasing]
GO
太难的解答我看不懂.不过谢谢各位了.
结贴!