TSQL - call stored proc

  • Hi

    I am writing a stored proc. I have declared a var inside the sproc.

    DECLARE @recipients varchar(100)

    Now I am trying to populate this with the output of another sproc.

    SELECT @recipients = 'exec '+ 'sp_Getmail ' + 'xyz'

    This is not working..any suggestions.

    Thanks

  • What error do you receive? Is it a syntax one?

    I would tend to do this:

    DECLARE @recipients varchar(100)

    exec sp_Getmail 'xyz', @recipients OUT

    SELECT @recipients

  • Hi

    If I want to set the return value of a stored procedure to a variable, this is how I would do

    declare @int as int

    Exec @int = uspGetEmployeeManagers 12

    PRINT @int

    If I want to set the output parameter of a stored procedure, this is how I would do,

    declare @int as int

    Exec sp_storedProcedwithoutparam @int output

    PRINT @int

    I am not sure if this answers your question 🙂

    Pakki

    ---------------------------------------------------------------------------------

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply