问题
I have this stored procedure:
ALTER PROCEDURE spCertificationType
@result nvarchar(15) output,
@mode int
AS
BEGIN
if @mode = 1
begin
exec spGeneratedID 2, @result output
print @result
end
END
but when I tried to execute it,it has this error
The formal parameter “@mode” was not declared as an OUTPUT parameter, but the actual parameter passed in requested output.
I tried to set @mode as output like this:
ALTER PROCEDURE spCertificationType
@result nvarchar(15) output,
@mode int output
AS
BEGIN
if @mode = 1
begin
exec spGeneratedID 2, @result output
print @result
end
END
but the it returns a null value.
Any fix for this? Thanks in advance.
回答1:
the sequence of parameter in store procedure is that first use input parameter then use output parameter:- you can see this link for more knowledge of store procedure:-
http://www.codeproject.com/Articles/126898/Sql-Server-How-To-Write-a-Stored-Procedure-in-SQL
ALTER PROCEDURE spCertificationType
@mode int,
@result nvarchar(15) output
AS
BEGIN
if @mode = 1
begin
exec spGeneratedID 2, @result output
print @result
end
END
回答2:
I fixed this error a different way.
- I had removed the OUTPUT statement after a parameter in my SP.
- I then got the error.
- I then went back to the SQLDataSource Configure Data Source wizard and went through the steps again. I discovered that changing the SP made the wizard delete the settings associated with the parameter that used to have OUTPUT after it.
来源:https://stackoverflow.com/questions/32219733/the-formal-parameter-mode-was-not-declared-as-an-output-parameter-but-the-ac