This is just one of those little reminders to self. Self, you never seem to remember how to assign the return value from a stored procedure to a variable in SQL. I try various forms and always seem to miss the right one. So, in an effort to mark it for my future use, I place it here in the blog.
One does NOT accomplish it through any of these methods:
DECLARE @ReturnedValue INT
SET @ReturnedValue = StoredProcedure @Param1, @Param2
IF( @ReturnedValue = @Something )
BEGIN
--Do This Stuff
END
SET @ReturnedValue = StoredProcedure ( @Param1, @Param2 )
SET @ReturnedValue = EXEC StoredProcedure @Param1, @Param2
SET @ReturnedValue = EXEC StoredProcedure ( @Param1, @Param2 )
One does by this method:
EXEC @ReturnedValue = StoredProcedure @Param1, @Param2
I just have to remember the order. I suppose it makes sense when I see it, but I forget when it's time to type it. It's just too easy to get mixed up with Function format.
© Copyright 2008 Rich Claussen Theme design by Bryan Bell / Rich Claussen newtelligence dasBlog 1.9.7174.0 | | Page rendered at Monday, December 01, 2008 6:44:38 PM (Pacific Standard Time, UTC-08:00) Reset | BlogXP | business | calmBlue | candidBlue | Candid Blue Real | dasBlog | dasblogger | DirectionalRedux | Discreet Blog Blue | Elegante | essence | Just Html | MadsSimple | Mobile | Mono | Movable Radio Blue | Movable Radio Heat | nautica022 | orangeCream | Portal | Project84 | Project84Grass | Slate | Sound Waves | Tricoleur | useit.com | Voidclass2