我正在调用这样的存储过程:
EXEC usp123 @F1 = 1, @F2 = 'A', @F3 = 5
DECLARE @Result int
SET @Result = (EXEC usp123 @F1 = 1, @F2 = 'A', @F3 = 5)
如何将变量分配给此存储过程的输出,因为上述语法不起作用..
答案 0 :(得分:1)
最后一行应该是
Declare @Result Int
EXEC @Result = usp123 @F1 = 1, @F2 = 'A', @F3 = 5
答案 1 :(得分:0)
--Check this... your answer is in the last sentence.
DECLARE @IntVariable int;
DECLARE @SQLString nvarchar(500);
DECLARE @ParmDefinition nvarchar(500);
DECLARE @max_title varchar(30);
SET @IntVariable = 197;
SET @SQLString = N'SELECT @max_titleOUT = max(JobTitle)
FROM AdventureWorks2012.HumanResources.Employee
WHERE BusinessEntityID = @level';
SET @ParmDefinition = N'@level tinyint, @max_titleOUT varchar(30) OUTPUT';
EXECUTE sp_executesql @SQLString, @ParmDefinition, @level = @IntVariable,
@max_titleOUT=@max_title OUTPUT;
SELECT @max_title;