早教吧作业答案频道 -->其他-->
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存储过程不启做...的网友还看了以下:
一个国标汉字使用多少位二进制数进行编码我知道是16位可书上说“在国标码的编码方式中,汉字字符集中任 2020-05-16 …
编制一个程序,其实现的功能是:对一个数字采集系统采集的50个字节无符号数按算术平均数字滤波方法 2020-05-23 …
给肥皂剧下一个定义50字50个字就够了上限50个字 2020-06-05 …
C++习题法师为了战胜妖魔,准备好了可以记为1,2,……,N的N类符咒字法师为了战胜妖魔,准备好了 2020-06-23 …
以下运算符优先级最高的是()A.逻辑运算符B.算术运算符C.文字运算符D.关系运算符 2020-06-26 …
求“自己拯救自己”一书的读后感,斯迈尔斯写的,1000字以上.符合要求的50分献上. 2020-06-27 …
为了书写和学术交流的方便,化学上常用元素符号和数字的组合表示物质组成的式子,请从Ca、C、O、H、 2020-07-03 …
50+40+30=40+50+30符合加法交换律吗如题 2020-07-31 …
用9、7、8、4、6、0、0、0、0、0这十个数字组成符合下面要求的数.(1)最大的八位数(2)最小 2020-11-20 …
有关环保的句子50字!环保!50字!50字! 2021-02-02 …