Click here to Skip to main content
15,881,742 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how we return value from sql stored procedure using return keyword?
Posted
Comments
VJ Reddy 30-May-12 7:42am    
Thank you, bhoopendrasharma, for accepting the solution :)

As explained here
http://msdn.microsoft.com/en-us/library/ms174998.aspx[^]
RETURN statement exits unconditionally from a query or procedure. RETURN is immediate and complete and can be used at any point to exit from a procedure, batch, or statement block. Statements that follow RETURN are not executed.
 
Share this answer
 
Comments
Maciej Los 23-May-12 2:09am    
Good answer, my 5!
VJ Reddy 23-May-12 2:09am    
Thank you, losmac :)
Wendelius 23-May-12 2:11am    
Yep, always good to read docs :)
VJ Reddy 23-May-12 2:15am    
Thank you, Mika :)
Mohamed Mitwalli 23-May-12 3:40am    
5+
For example
SQL
CREATE PROCEDURE Test AS
BEGIN
   RETURN 1;
END;

For example and explanations, please refer to RETURN [^]
 
Share this answer
 
Comments
Maciej Los 23-May-12 2:09am    
Good answer, my 5!
Wendelius 23-May-12 2:11am    
Thanks :)
VJ Reddy 23-May-12 2:09am    
Good answer. 5!
Wendelius 23-May-12 2:11am    
Thanks :)
Mohamed Mitwalli 23-May-12 3:40am    
5+
SQL
CREATE PROCEDURE Test AS
BEGIN
   RETURN 1;
END;
 
Share this answer
 
Comments
Prasad_Kulkarni 23-May-12 3:32am    
Same answer, just bit late i think..
anyways have my 5!
AspDotNetDev 23-May-12 19:12pm    
Why have you copied the other answer?
Sandeep Mewara 24-May-12 2:19am    
Avoid copy-paste! :doh:
SQL
CREATE PROCEDURE Usp_ReturnTest
@I_No int=1,
@II_No int=2
AS
BEGIN
   RETURN isnull(@I_No,0)+isnull(@II_No,0)
END
 
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