可以。create proc _sp2 as update #temp set id=id*10 go create proc _sp1 ascreate table #temp (id int)insert into #temp select 1print '_sp1中:执行_sp2前' select * from #tempexec _sp2print '_sp1中:执行_sp2后' select * from #tempGO exec _sp1 drop proc _sp1,_sp2
没有问题。create proc _sp2 as begin update #temp set id=id*10 end gocreate proc _sp1 as begin create table #temp (id int) insert into #temp select 1 print '_sp1中:执行_sp2前' select * from #temp exec _sp2 print '_sp1中:执行_sp2后' select * from #temp end GO exec _sp1 drop proc _sp1,_sp2
as
update #temp set id=id*10
go
create proc _sp1
ascreate table #temp (id int)insert into #temp select 1print '_sp1中:执行_sp2前'
select * from #tempexec _sp2print '_sp1中:执行_sp2后'
select * from #tempGO
exec _sp1
drop proc _sp1,_sp2
as
begin
update #temp set id=id*10
end
gocreate proc _sp1
as
begin
create table #temp (id int) insert into #temp select 1 print '_sp1中:执行_sp2前'
select * from #temp exec _sp2 print '_sp1中:执行_sp2后'
select * from #temp
end
GO
exec _sp1
drop proc _sp1,_sp2
创建了一存储过程A,在其中建一临时表#temp,有四个字段a,b,c,d,在存储过程A中已经把前三个字段a,b,c更新完,第四个字段d需要用前三个字段做复杂计算才能得到,考虑到可能还要进行插入操作,就单独建立了一存储过程B进行处理字段d,问对于#temp中已有数据只能利用游标一行一行处理吗?
方法很多:看情况而定,可能的方法:动态查询、游标、循环等等
看个人的能力和SQL查询效率而定