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.
IN OUT mode: You can assign values to the formal parameter at runtime when using an IN OUT mode variable. At the conclusion of the function or procedure the internal variable's reference is passed to the calling program scope and replaces the original reference to the actual parameter.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With