Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to set value of procedure to variable? Expand / Collapse
Author
Message
Posted Sunday, September 8, 2013 6:56 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, November 6, 2013 10:29 AM
Points: 4, Visits: 93
Hello mates.
I want to create a procedure with follow two sentences.

  DECLARE @Wallet int
SET @Wallet = EXEC HowMoneyIsInTheWallet @IDOsoby

And I have this error: Incorrect syntax near the keyword 'EXEC'.
How resolve the problem ?
Post #1492592
Posted Sunday, September 8, 2013 10:17 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, September 18, 2014 6:28 AM
Points: 94, Visits: 333
Hi sasia
you need to define output parameter to your procedure
for example
create procedure HowMoneyIsInTheWallet
(
@IDOsoby int,
@Wallet int OUTPUT
)
AS
-- your code where you set value to @Wallet
return @Wallet


call the stored procedure

DECLARE @WalletReturned int, @Wallet int

EXEC @WalletReturned = HowMoneyIsInTheWallet @IDOsoby, @Wallet output
print @WalletReturned
Post #1492604
Posted Sunday, September 8, 2013 12:13 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, November 6, 2013 10:29 AM
Points: 4, Visits: 93
Thank you SrcName for your answer.
You help me, and i am thankfull you for that :)
I wish you have a nice day :D
Enjoy
Post #1492612
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse