如何在存储过程中使用游标,调用其他存储过程,或者执行相关函数
展开全部
大概意思如下,具体表或栏位改成你自己的吧
declare cur_name cursor for select type from table1; --定义游标
declare @type varchar(50);
open cur_name;
fetch next from cur_name into @type;
while @@fetch_status =0
begin
if @type = '存储过程'
begin
exec 存储过程;
end
else if @type = 函数
begin
select dbo.函数();
end
fetch next from cur_name into @type;
end
close cur_name;
deallocate cur_name;
declare cur_name cursor for select type from table1; --定义游标
declare @type varchar(50);
open cur_name;
fetch next from cur_name into @type;
while @@fetch_status =0
begin
if @type = '存储过程'
begin
exec 存储过程;
end
else if @type = 函数
begin
select dbo.函数();
end
fetch next from cur_name into @type;
end
close cur_name;
deallocate cur_name;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询