• λ我爱Aspx >> Asp.Net >> 存储过程分页
  • 存储过程分页

  • :未知  Դ:internet  :2007-5-20 16:44:46  ؼ:
  • --如果显示第一页,可以直接用top来完成

    if @PageCurrent=1

    begin

    select @Id1=cast(@PageSize as varchar(20))

    exec('select top '+@Id1+@FdShow+' from '+@QueryStr+@FdOrder)

    return

    end

    --如果是表,则检查表中是否有标识更或主键

    if @Obj_ID is not null and objectproperty(@Obj_ID,'IsTable')=1

    begin

    select @Id1=cast(@PageSize as varchar(20))

    ,@Id2=cast((@PageCurrent-1)*@PageSize as varchar(20))

    select @FdName=name from syscolumns where id=@Obj_ID and status=0x80

    if @@rowcount=0 --如果表中无标识列,则检查表中是否有主键

    begin

    if not exists(select 1 from sysobjects where parent_obj=@Obj_ID and xtype='PK')

    goto lbusetemp --如果表中无主键,则用临时表处理

    select @FdName=name from syscolumns where id=@Obj_ID and colid in(

    select colid from sysindexkeys where @Obj_ID=id and indid in(

    select indid from sysindexes where @Obj_ID=id and name in(

    Ҷƪл˵?
  • һƪSQL Server 索引结构及其使用(一)
    һƪSQL在存储过程中使用递归