This Domain(Admin5.com) is for Sale:

分页 SQLServer数据库存储过程

时间:2007-12-23  来源:不详  作者:迈克DB

select name from sysobjects where xtype='PK' and parent_obj=@Obj_ID
)))
select @strfd=substring(@strfd,2,2000)
,@strjoin=substring(@strjoin,5,4000)
,@strwhere=substring(@strwhere,5,4000)
goto lbusepk
end
end
end
else
goto lbusetemp

织梦好,好织梦

/*--使用标识列或主键为单一字段的处理方法--*/
lbuseidentity:
exec('select top ' @Id1 @FdShow ' from ' @QueryStr
' where ' @FdName ' not in(select top '
@Id2 ' ' @FdName ' from ' @QueryStr @FdOrder
')' @FdOrder
)
return

织梦内容管理系统

/*--表中有复合主键的处理方法--*/
lbusepk:
exec('select ' @FdShow ' from(select top ' @Id1 ' a.* from
(select top 100 percent * from ' @QueryStr @FdOrder ') a
left join (select top ' @Id2 ' ' @strfd '
from ' @QueryStr @FdOrder ') b on ' @strjoin '
where ' @strwhere ') a'
)
return 本文来自织梦

/*--用临时表处理的方法--*/
lbusetemp:
select @FdName='[ID_' cast(newid() as varchar(40)) ']'
,@Id1=cast(@PageSize*(@PageCurrent-1) as varchar(20))
,@Id2=cast(@PageSize*@PageCurrent-1 as varchar(20)) 本文来自织梦

exec('select ' @FdName '=identity(int,0,1),' @FdShow '
into #tb from' @QueryStr @FdOrder '
select ' @FdShow ' from #tb where ' @FdName ' between '
@Id1 ' and ' @Id2
) 织梦内容管理系统

GO copyright dedecms

copyright dedecms


看完这篇,您有何感觉呢?

文章评论

共有位Admini5网友发表了评论 查看完整内容

24小时热门信息