Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 存储过程中的输出参数不工作_Sql_Sql Server 2005_Stored Procedures - Fatal编程技术网

Sql 存储过程中的输出参数不工作

Sql 存储过程中的输出参数不工作,sql,sql-server-2005,stored-procedures,Sql,Sql Server 2005,Stored Procedures,我不熟悉存储过程 我有两个数字相加的简单存储过程,如下所示: alter proc simpleProc ( @Tax int , @TotalAmount int, @sum int output ) as BEGIN set @sum=(@Tax+@TotalAmount) print @sum END exec simpleProc 908,82 正如我们在@sum中看到的,sum是输出参数 但当我按如下方式执行时: alter proc simp

我不熟悉存储过程

我有两个数字相加的简单存储过程,如下所示:

alter proc simpleProc 
(
    @Tax int ,
    @TotalAmount int,
    @sum int output     
)
as
BEGIN
set @sum=(@Tax+@TotalAmount)
print @sum
END
exec simpleProc 908,82 
正如我们在
@sum
中看到的,sum是输出参数

但当我按如下方式执行时:

alter proc simpleProc 
(
    @Tax int ,
    @TotalAmount int,
    @sum int output     
)
as
BEGIN
set @sum=(@Tax+@TotalAmount)
print @sum
END
exec simpleProc 908,82 
它给了我以下错误:

Msg 201,16级,状态4,程序simpleProc,第0行
过程或函数“simpleProc”需要未提供的参数“@sum”

我已经提到了作为输出参数的
@sum
,但是它也要求我输入
@sum
参数


可能有什么错误?

您应该为过程提供一个变量,用于存储输出

declare @sum int
exec simpleProc 908, 82, @sum output

是的,如果您没有提供输出参数。 试试这个