none
Call Stored Procedure With Parameters RRS feed

  • Question

  • Greetings, I want to call a stored procedure with parameters and store the result in a variable.  So essentially from stored procedure A call stored procedure B 

    This is my syntax but I get this error: 

    Msg 102, Level 15, State 1, Line 6
    Incorrect syntax near '@begin'.

    And this is my syntax - (as well as the start of procedure B showing the parameters it accepts)

    Declare @abncd decimal(18,4), @begin datetime, @end datetime, @employeename varchar(50)
    
    Set @begin = '10/01/2015'
    Set @end = '10/06/2015'
    Set @employeename = 'Jose Whiskey'
    Set @abncd = ([dbo].[alphanumerics] @begin, @end, @employeename)
    
    
    ALTER procedure [dbo].[alphanumerics]
    (
    	@begin datetime,
    	@end datetime,	
    	@employeename varchar(100)
    )


    EDIT ---

    I see now that if I use this syntax it will execute the stored procedure, BUT I want the returned result to be stored in my variable...and this only executes and returns the value from stored procedure 2

    exec @abncd = ([dbo].[alphanumerics] @begin, @end, @employeename)
    Monday, October 19, 2015 4:04 PM

Answers