Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE  sp_Division
		 @Result FLOAT
AS
BEGIN TRY

	SET @Result = 10/5
	DECLARE @Check AS FLOAT

	PRINT '--> '+CONVERT(CHAR(255),@Result);


END TRY  

BEGIN CATCH  
    IF @Check=0
	PRINT 'Error, can not divide with 0'
END CATCH;  
GO

What I have tried:

I have put this in procedure and then executed the procedure, and it gives me an error
Procedure or function 'sp_Division' expects parameter '@Result', which was not supplied.
Posted
Updated 19-Aug-19 21:41pm

Try:
SQL
CREATE PROCEDURE  sp_Division
		 @Result FLOAT OUTPUT
AS
 
Share this answer
 
Comments
NikolV 20-Aug-19 4:47am    
Thank you .It worked
OriginalGriff 20-Aug-19 5:02am    
You're welcome!
Change

SQL
CREATE PROCEDURE  sp_Division
		 @Result FLOAT


into

SQL
CREATE PROCEDURE  sp_Division
		 @Result FLOAT = NULL


OR
SQL
CREATE PROCEDURE  sp_Division


The strange thing is That you create a stored procedure that needs @Result als parameter and in the sp you devide 10/5 and store that in @Result.
 
Share this answer
 
v2

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