select the output of stored procedure with count of returned rows

  • I want to select the output of stored procedure and the count of the row affected

    So am trying to do something like that

    select * , count(*)

    (

    if @checker is not null

    begin

    exec [dbo].[GetEmployees]

    @parameter1,

    @parameter2

    end

    else

    begin

    exec [dbo].[GetEmployees]

    @parameter3,

    @parameter4

    end

    )T

    I always get error like this

    Incorrect syntax near the keyword 'if'.

    Incorrect syntax near ')'.

  • ok so you are trying to execute stored proc inside join. Also the IF statement should be outside.

    If you can get the date from this stored proc and then count the records.

    I am not sure the data set returned but you can.

    IF @checker is not null

    BEGIN

    INSERT INTO #temp

    (

    column1

    ,column2

    ,....

    exec [dbo].[GetEmployees]

    @parameter1,

    @parameter2

    END

    ELSE

    BEGIN

    INSERT INTO #temp

    (

    column1

    ,column2

    ,....

    exec [dbo].[GetEmployees]

    @parameter3,

    @parameter4

    END

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

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