1. Getting result from a stored procedure as a RESULT SET (Multi Column / Scalar value)
Create Proc USP_Sample1
(
@InParamater1 Varchar(25) =''
)As
Begin
Set Nocount On
Select 'Welcome ...' + ISNULL(@InParamater1,'') [Result]
End
Go
Exec USP_Sample1 'Pandian'
Go
2. Getting result from a stored procedure as an OUTPUT Parameter
Create Proc USP_Sample2
(
@InParamater1 Varchar(25) ='',
@OutParamater1 Varchar(25) Output
)As
Begin
Set Nocount On
Select @OutParamater1 = 'Welcome ...' + ISNULL(@InParamater1,'')
End
Go
Declare @Result Varchar(25)
Exec USP_Sample2 'Pandian', @Result Output
Select @Result [Result]
Go
3. Getting result from a stored procedure as a RETURN
Create Proc USP_Sample3
(
@InParamater1 Int =0
)As
Begin
Set Nocount On
Return @InParamater1
End
Go
Declare @Result Int
Exec @Result = USP_Sample3 100
Select @Result [Result]
Go
Note:
RETURN supports only Numeric data!
Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions
Jasminej, if this helps please login to Mark As Answer. |
Reply | Alert Moderator