Can I give name for a result set?

  • hi!

    i have a stored procedure with two SELECT and IF statements, like this:

    CREATE PROCEDURE dbo.Proc1

    @a bit= 1

    , @b-2 bit= 0

    AS

    IF @a= 1 SELECT * FROM dbo.TableA

    IF @b-2= 1 SELECT * FROM dbo.TableB

    GO

    depend on the values of variables i can get 0, 1, 1, or 2 tables as the result of the query.

    this SP is used by an application, what need to know, which is the result-table.

    is there any way to give name to the result-table?

    thx for the answers,

    bye

    G

  • The best solution would be to create 4 separate procs to handle all possible cases (actually 1 per table combinaison). Have that proc call the appropriate procedure. If you fear that many more parameters like this may be added, then you might have to rethink the table design or need to move to dynamic sql (yes that happens so times 🙁 ).

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

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