Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all
I am using SQL server and I created a store procedure but I am getting following error

VB
Server: Msg 201, Level 16, State 4, Procedure SP_New_OrderNo, Line 0
Procedure 'SP_New_OrderNo' expects parameter '@ERROR', which was not supplied.


Can any one please help me?

Bellow I am giving my Sore procedure

SQL
CREATE PROCEDURE SP_New_OrderNo @CustomerNo NVARCHAR(10), @ModelNo NVARCHAR(10), @ERROR VARCHAR(100)OUTPUT
AS
BEGIN
SET NOCOUNT ON;
DECLARE @CusNo NVARCHAR(50)
DECLARE @MdlNo NVARCHAR(50)
SELECT @CusNo=CustomerNo, @MdlNo=ModelNo FROM TblSerialNo WHERE CustomerNo=@CustomerNo
IF @CusNo=@CustomerNo
BEGIN
IF @MdlNo=@ModelNo
BEGIN
SET @ERROR  = 'THIS CUSTOMER NO. AND MODEL NO. IS IN DATABASE PLEASE ENTER SERIAL NUMBER'
END
ELSE
BEGIN
SET @ERROR  = 'THIS CUSTOMER NO. IS IN DATABASE PLEASE ENTER MODELNO AND SERIAL NUMBER'
END
END
ELSE
BEGIN
SET @ERROR  = 'PLEASE ENTER CUSTOMER NO.'
INSERT INTO TblSerialNo (CustomerNo, ModelNo) VALUES (@CustomerNo, @ModelNo)
END

END

GO

EXEC SP_New_OrderNo '111','123'


Thanks To all
Posted

Since you also have additional field as output parameter, instead of executing SP as
SQL
EXEC SP_New_OrderNo '111','123'

you need to do something like:
SQL
declare @error varchar(100)
exec yourStoredProcedureName '111','123', @error output
print @error
 
Share this answer
 
Comments
Manas Bhardwaj 15-Jun-12 3:59am    
Correct +5
I hope there is a space in the definition at the top:
SQL
@ERROR VARCHAR(100) OUTPUT


Now, error comes as you have not supplied the thrid parameter. Even though it is marked as OUTPUT, it's defined as one of the parameters for SP. So, try:
SQL
EXEC SP_New_OrderNo '111','123', @ERROR OUTPUT
SELECT @ERROR


Refer:
MSDN: Using a Stored Procedure with Output Parameters[^]
Stored Procedures: Returning Data[^]
Executing a stored procedure with OUTPUT parameters from Query window[^]
 
Share this answer
 
Comments
Manas Bhardwaj 15-Jun-12 3:59am    
Correct +5
The error says it all! You need to give something to receive the out parameter of the procedure.

See http://sqlserverplanet.com/tsql/how-to-call-a-stored-procedure[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900