) ,@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
关注此文的读者还看过:
- 2010-4-1 18:12:45 预防非法表D99_Tmp,kill_kk的建立
- 2008-4-23 15:53:39 SQL Server数据库超级管理员账号防护知识
- 2008-4-11 21:37:35 SQL Server 2005数据库镜像配置脚本示例
- 2008-4-4 9:12:54 讲解如何实现互联网上数据库的安全
- 2008-4-1 11:07:24 SQL 2005数据库转到SQL 2000的步骤讲解
- 2008-3-31 12:39:45 SQL Server自动生成日期加数字的序列号
- 2008-3-31 12:39:07 SQL Server 2000的数据库容量究竟是多大
- 2008-3-18 18:01:49 SQL Server 2005数据库的同义词Bug 讲解
|