早教吧作业答案频道 -->其他-->
sqL2000存储过程不启做用--CREATEPROCEDURE[dbo].[getProductsTable]@actionnvarchar(50),--确定返回值@keysnvarchar(100),--用户输入的关键字符串@pageIndexint,--返回第几页@productCountint--每页商品数ASBEGIN--定义临
题目详情
sqL2000存储过程 不启做用
--
CREATE PROCEDURE [dbo].[getProductsTable]
@action nvarchar(50),--确定返回值
@keys nvarchar(100),--用户输入的关键字符串
@pageIndex int,--返回第几页
@productCount int--每页商品数
AS
BEGIN
--定义临时表@t,存储过程productSearch的结果放在这里
create table #t(productname nvarchar(200),whichtableid bigint,whichrowid bigint)
insert into #t(productname,whichtableid,whichrowid)
exec productSearch @action,@keys,@pageIndex,@productCount
select * from #t
declare @strSql nvarchar(4000)--定义sql语句存放的地方
declare @theProName nvarchar(200)--定义3个变量,遍历时分别用于存储各个字段
declare @theTableId bigint
declare @theRowid bigint
declare @theTableName nvarchar(100)
declare @cursor cursor --定义游标用游标拼接sql语句
set @cursor = cursor for
select * from #t
open @cursor
fetch next from @cursor into @theProName,@theTableId,@theRowid
while(@@FETCH_STATUS=0)
begin
select @theTableName=tablename from type1 where id = ltrim(@theTableId)
set @strSql =@strSql+' union select * from '+@theTableName+' where id='+ltrim
(@theRowid)
fetch next from @cursor into @theProName,@theTableId,@theRowid
end
close @cursor
deallocate @cursor
set @strSql = STUFF(@strSql,1,6,'')
set @strSql=@strSql
exec(@strSql)
END
GO
--
CREATE PROCEDURE [dbo].[getProductsTable]
@action nvarchar(50),--确定返回值
@keys nvarchar(100),--用户输入的关键字符串
@pageIndex int,--返回第几页
@productCount int--每页商品数
AS
BEGIN
--定义临时表@t,存储过程productSearch的结果放在这里
create table #t(productname nvarchar(200),whichtableid bigint,whichrowid bigint)
insert into #t(productname,whichtableid,whichrowid)
exec productSearch @action,@keys,@pageIndex,@productCount
select * from #t
declare @strSql nvarchar(4000)--定义sql语句存放的地方
declare @theProName nvarchar(200)--定义3个变量,遍历时分别用于存储各个字段
declare @theTableId bigint
declare @theRowid bigint
declare @theTableName nvarchar(100)
declare @cursor cursor --定义游标用游标拼接sql语句
set @cursor = cursor for
select * from #t
open @cursor
fetch next from @cursor into @theProName,@theTableId,@theRowid
while(@@FETCH_STATUS=0)
begin
select @theTableName=tablename from type1 where id = ltrim(@theTableId)
set @strSql =@strSql+' union select * from '+@theTableName+' where id='+ltrim
(@theRowid)
fetch next from @cursor into @theProName,@theTableId,@theRowid
end
close @cursor
deallocate @cursor
set @strSql = STUFF(@strSql,1,6,'')
set @strSql=@strSql
exec(@strSql)
END
GO
▼优质解答
答案和解析
近期帮你看下,解决了告诉你!—@飘摇诗涯
看了 sqL2000存储过程不启做...的网友还看了以下:
下面的叙述中,正确的是______。A.采用串行通信方式时,数据经过2根传输线被逐位顺序传输B.采用 2020-05-23 …
在下列叙述中,正确的一条是( )A.采用串行数据通信时,数据在传输线上是一位一位地传输,因此发送 2020-05-24 …
下列贷款中,贷款期限上限最高的是( )。 A.商用车消费贷款 B.一般商业性助学贷款 C. 2020-05-30 …
以下各项中,贷款担保方式其他三项完全不同的是( )。A.商用房贷款 B.有担保流动资金贷款C.设备 2020-06-27 …
以下关于商用房贷款利率说法正确的是( )。A.商用房贷款的利率不得低于中国人民银行规定的同期 2020-06-27 …
以下各项中,贷款担保方式其他三项完全不同的是( )。 A.商用房贷款 B.有担保流动资金贷款 C.设 2020-06-27 …
办理商用房贷款时,对申请人进行贷前调查的内容包括( )。A.商用房开发商的资信情况 B.贷 2020-06-27 …
下列贷款中,贷款期限上限最高的是( )。 A.商用车消费贷款B.一般商业性助学贷款 C.二手车消费贷 2020-06-27 …
以下选项中,贷款担保方式与其他三项完全不同的是( )。A.商用房贷款B.有担保流动资金贷款C.设备贷 2020-06-27 …
社区物业管理主要是对社区内()的管理.A.商用物业B.居住物业C.工业物业D.其他用途物业 2020-12-11 …