Sql 从另一个存储过程调用三个存储过程

Sql 从另一个存储过程调用三个存储过程,sql,sql-server,Sql,Sql Server,我已经执行了3个存储过程。但是现在我想在一个过程中调用它们 Proc1 @PTID int select A.AId from Table1 A where A.Id = @PID Proc2 @PID int, @AID int Insert into Table2 (PID, AID) values (@PID, @AID) Proc3 @AID int, @PID int Insert into Table3 (AID,WID,PID) select AD,WID,@PID fr

我已经执行了3个存储过程。但是现在我想在一个过程中调用它们

Proc1

@PTID int
select A.AId from Table1 A  where A.Id = @PID
Proc2

@PID int,
@AID int
Insert into Table2 (PID, AID) values (@PID, @AID)
Proc3

@AID int,
@PID int


Insert into Table3 (AID,WID,PID)
select AD,WID,@PID from Table1 where AID = @AID 
现在,调用所有这3个过程的过程

主程序

@PTID int;
@PID int;

Declare @aid int
set @aid=EXEC Proc1 @PID  //I want to get a list of aid, but I get ERROR here saying Incorrect Syntax

exec Proc2 (@PID, @aid)

exec Proc3(@aid)
我的Proc1、Proc2和Proc3运行良好。但是我在
主进程中得到错误

如果我想在
Main Proc
中调用所有这3个存储过程,我该如何实现

更新:

主程序中出错

关键字“EXEC”附近的语法不正确


尝试像这样更改
proc3

Insert into Table3 (AID,WID,PID)
select AD,WID,@PID from Table1 where AID = @AID 

你能添加你得到的错误消息吗?你没有在proc3上丢失一个参数吗?如果你想为从Proc1得到的每一行调用Proc2&3一次,你需要使用游标。@Lamak我在表1中只有2列,所以如果我从表1中得到2列,我不知道如何在表3中插入3列。好的,你的问题很模糊,我们不知道您得到的是什么错误,也不知道您想要做什么。Table1只有2列。所以,我得到了这两列,想插入第三列的值pass@user1989-我就是这么做的是的,我明白了。谢谢你能告诉我,我如何使用,这些在主程序中。