--假如显现第一页,能够间接用top来完成
if@PageCurrent=1
begin
select@Id1=cast(@PageSizeasvarchar(20))
exec(selecttop+@Id1+@FdShow+from+@QueryStr+@FdOrder)
return
end
--假如是表,则反省表中是不是有标识更或主键
if@Obj_IDisnotnullandobjectproperty(@Obj_ID,IsTable)=1
begin
select@Id1=cast(@PageSizeasvarchar(20))
,@Id2=cast((@PageCurrent-1)*@PageSizeasvarchar(20))
select@FdName=namefromsyscolumnswhereid=@Obj_IDandstatus=0x80
if@@rowcount=0--假如表中无标识列,则反省表中是不是有主键
begin
ifnotexists(select1fromsysobjectswhereparent_obj=@Obj_IDandxtype=PK)
gotolbusetemp--假如表中无主键,则用一时表处置
select@FdName=namefromsyscolumnswhereid=@Obj_IDandcolidin(
selectcolidfromsysindexkeyswhere@Obj_ID=idandindidin(
selectindidfromsysindexeswhere@Obj_ID=idandnamein(
selectnamefromsysobjectswherextype=PKandparent_obj=@Obj_ID
)))
if@@rowcount>1--反省表中的主键是不是为复合主键
begin
select@strfd=,@strjoin=,@strwhere=
select@strfd=@strfd+,[+name+]
,@strjoin=@strjoin+anda.[+name+]=b.[+name+]
,@strwhere=@strwhere+andb.[+name+]isnull
fromsyscolumnswhereid=@Obj_IDandcolidin(
selectcolidfromsysindexkeyswhere@Obj_ID=idandindidin(
selectindidfromsysindexeswhere@Obj_ID=idandnamein(
selectnamefromsysobjectswherextype=PKandparent_obj=@Obj_ID
)))
select@strfd=substring(@strfd,2,2000)
,@strjoin=substring(@strjoin,5,4000)
,@strwhere=substring(@strwhere,5,4000)
gotolbusepk
end
end
end
else
gotolbusetemp