Kindly Clarify: What are all the ways to get the Result from a Stored Procedure ?

Posted by Jasminej under Sql Server on 4/27/2012 | Points: 10 | Views : 813 | Status : [Member] | Replies : 2
What are all the ways to get the Result from a Stored Procedure ?

Kindly give me an example

Thank You




Responses

Posted by: Pandians on: 4/27/2012 [Member] [MVP] Silver | Points: 25

Up
0
Down
1. Getting result from a stored procedure as a RESULT SET (Multi Column / Scalar value)
[Code]Create Proc USP_Sample1
(
@InParamater1 Varchar(25) =''
)As
Begin
Set Nocount On
Select 'Welcome ...' + ISNULL(@InParamater1,'') [Result]
End
Go[/Code][Code]Exec USP_Sample1 'Pandian'
Go[/Code]

2. Getting result from a stored procedure as an OUTPUT Parameter
[Code]Create Proc USP_Sample2
(
@InParamater1 Varchar(25) ='',
@OutParamater1 Varchar(25) Output
)As
Begin
Set Nocount On
Select @OutParamater1 = 'Welcome ...' + ISNULL(@InParamater1,'')
End
Go[/Code][Code]Declare @Result Varchar(25)
Exec USP_Sample2 'Pandian', @Result Output
Select @Result [Result]
Go[/Code]

3. Getting result from a stored procedure as a RETURN
[Code]Create Proc USP_Sample3
(
@InParamater1 Int =0
)As
Begin
Set Nocount On
Return @InParamater1
End
Go[/Code][Code]Declare @Result Int
Exec @Result = USP_Sample3 100
Select @Result [Result]
Go[/Code]Note:
RETURN supports only Numeric data!


Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Jasminej, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jasminej on: 4/30/2012 [Member] Starter | Points: 25

Up
0
Down
Thank You very much

Jasminej, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response