sqlserver将查询结果作为参数传入存储过程
存储过程ClientCredit只需一个参数,然后我需要将selectdistinctf5fromtableAwheref2>='20140101'andf119<>'1...
存储过程 ClientCredit 只需一个参数,然后我需要将
select distinct f5 from tableA where f2>='20140101' and f119<>'1' and f58>0 and f100<>'Y' and f4='1' and f20='6' 的查询结果作为参数传入存储过程,该怎么实现?急急急 展开
select distinct f5 from tableA where f2>='20140101' and f119<>'1' and f58>0 and f100<>'Y' and f4='1' and f20='6' 的查询结果作为参数传入存储过程,该怎么实现?急急急 展开
展开全部
create or replace callproc
as
begin
for v (select distinct f5 from tableA where f2>='20140101' and f119<>'1' and f58>0 and f100<>'Y' and f4='1' and f20='6') loop
ClientCredit(v.f5);
end;
as
begin
for v (select distinct f5 from tableA where f2>='20140101' and f119<>'1' and f58>0 and f100<>'Y' and f4='1' and f20='6') loop
ClientCredit(v.f5);
end;
追答
上面是oracle语法
下面是sqlserver语法:
create callproc
CREATE CALLPROC
as
declare @v_f5 nvarchar(20)
declare cur cursor for select distinct f5 from tableA where f2>='20140101' and f119'1' and f58>0 and f100'Y' and f4='1' and f20='6')
OPEN CUR
FETCH NEXT FROM cur into @v_f5
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC ClientCredit(@v_f5);
FETCH NEXT FROM cur into @v_f5
END
CLOSE cur
DEALLOCATE cur
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询