create proc DingDan_Get
@startindex int,@pagesize int,@VIPID varchar(50),@ShopID int
as
begin
declare @where varchar(1000),@SQl varchar(1000)
set @where=' where 1=1 and'
if(len(@VIPID)>0)
set @where=@where+' VIP_ID='+@VIPID+' and'
if(@ShopID>0)
set @where=@where+' Shop_ID='+ltrim(@ShopID)+' and'
if(len(@where)>0)
Set @where=substring(@where,0,len(@where)-3)
set @SQL = 'select top ('+ltrim(@pagesize)+') * from DingDan_View '+@where +' and D_ID NOT IN
(
select top('+ltrim(@pagesize*@startindex)+') D_ID from DingDan '+@where +' order by D_ID desc
) order by D_ID desc'
exec(@SQL)
end
go
- 本文标题: SQL存储过程的len和substring的用法
- 文章分类:【SQLServer】
- 非特殊说明,本文版权归【胡同里的砖头】个人博客 所有,转载请注明出处.