omitting table-valued parameters

  • I'm creating a stored procedure that will be passed several table-valued parameters. Will I be able to tell whether a parameter was omitted or if the calling problem sent me an empty table?

    More detail (I'm pretty new at this, so I hope my terminology is understandable): From what I've read, if the calling program omits a table-valued parameter, the stored procedure creates an empty table. However, it's also possible that the calling program may have fed me an empty table. (The calling program is working with a dataset I fed it via another stored procedure, it's possible that the calling program may have deleted every row and is returning the empty table to me). I'd like the stored procedure to be able to discern the difference between the two situations, but I'm not sure that that's possible.

    If my question is unclear, please let me know, I'll try again.

    Thanks for your help!

  • I have not worked with table valued parameters, but it seems easy enough to test by passing a null to the parameter or an empty set and see what happens.

    Jared
    CE - Microsoft

  • Looks like if the parameter is omitted the sp still runs and assumes an empty table. I would have the set pass a row with some indicators to detect if the parameter was left off or if it is an "empty" set.

    Jared
    CE - Microsoft

  • SQLKnowItAll (5/23/2012)


    Looks like if the parameter is omitted the sp still runs and assumes an empty table. I would have the set pass a row with some indicators to detect if the parameter was left off or if it is an "empty" set.

    Makes sense, thanks!

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

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