从另一个存储过程调用包含参数和输出参数的存储过程?

时间:2011-08-18 07:32:49

标签: sql tsql

这只是一个展示的例子。

存储过程A:

Create PROCEDURE InsertNode

@ID nvarchar(64),
@Name nvarchar(64),
@Total int OUTPUT
AS
INSERT INTO [TableA] (ID,Name) VALUES (@ID, @Name)
SELECT @Total = Count(*) FROM TableA

存储过程B:

Create PROCEDURE CallInsertNode

@InputID nvarchar(64),
@InputName nvarchar(64),
@ResultTotal
AS
EXEC InsertNode ...// how can I define the input params(@InputID, @Input Name) and output param (@ResultTotal) for Stored procedure A (like passing parameters)?

谢谢。

1 个答案:

答案 0 :(得分:2)

EXEC InsertNode 
    @Id = @InputId,
    @Name = @InputName,
    @Total = @ResultTotal OUTPUT