A Stroed Procedure in side a StoredProcedure

  • How do we get value in 1x1 table returning from a Stroed Procedure in side a StoredProcedure without using temprery table in main stroed Procedure.

    thanks,

    Anoop

    Please help anybody

  • Please can explain in detail and with an example.

  • Yes Anoop, please explain it further.

  • suppose I have a sp which returns boolean value 0 or 1 how can we get that value in another procedure in which we calling first sp.

  • Hi Anoop

    You can take the output of calling sp using output parameter. Alternatively you can use udf also.

    Thanx

    Vaseem

  • suppose I have a sp which returns boolean value 0 or 1 how can we get that value in another procedure in which we calling first sp.

    Refer following code:

    declare @a int

    execute @a = test

    print @a

    Here test is the sp which returns a value 0 or 1.

  • Sorry i have tryed it is not working.

  • Thanks vaseem

    grate job!

  • Sorry i have tryed it is not working.

    Try this code

    create proc test

    as begin

    return 1

    end

    GO

    create proc test1

    as begin

    declare @a int

    execute @a = test

    print @a

    end

    execute test1

    Here in the above code test1 sp is calling test sp which returns 1.

    test1 sp will get the value 1 and it will print the value.

    This is how you can can the sp which is returning a value.

    You can also use a output variable to achieve the same thing.

  • thanks Gauthama

    🙂

  • You can also use OUTPUT parameters.

    CREATE PROCEDURE proc1

    (@param1 INT

    ,@param2 INT OUTPUT)

    AS

    SET @param2 = @param1 ;

    GO

    CREATE PROCEDURE proc2

    AS

    DECLARE @myparam INT ;

    EXEC proc1 @param1 = 42, @param2 = @myparam OUTPUT ;

    SELECT @myparam ;

    GO

    EXEC proc2 ;

    ----------------------------------------------------The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore RooseveltThe Scary DBAAuthor of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd EditionProduct Evangelist for Red Gate Software

Viewing 11 posts - 1 through 10 (of 10 total)

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