分页查询&&top后面的参数

来源:互联网 发布:arduino串口发送数据 编辑:程序博客网 时间:2024/05/19 22:46

--可以用于分页查询
--本句查询一个表中的第几行记录
alter proc pr_get_oneimage  
 @count int,
 @albumid int
as
declare @s varchar(8000)
set @s='select top 1 imagebyte  from c_image where albumid='
+cast(@albumid as varchar(100)) + 'and
 imageid not in (select top '+ cast(@count as varchar(100))+
' imageid from c_image)'

exec (@s)