• Steven Willis (8/27/2013)


    Hey...I found the answer:

    Erland Sommarskog, SQL Server MVP. 2013-03-24.

    How to Share Data between Stored Procedures

    "Another solution, which requires SQL 2008, comes from Wayne Bloss. He creates a table type that holds the definition of the temp table. You can only use table types for declaring table variable and table parameters. But Wayne has a cure for this:

    DECLARE @dummy my_table_type

    SELECT * INTO #mytemp FROM @dummy

    From this point you work with #mytemp; the sole purpose of @dummy is to be able to create #mytemp from a known and shared definition. (If you are unacquainted with table types, we will take a closer look on them in the section on table-valued parameters.) A limitation with this method is that you can only centralise column definitions this way, but not constraints as they are not copied with SELECT INTO. You may think that constraints are odd things you rarely put in a temp table, but I have found that it is often fruitful to add constraints to my temp tables as assertions for my assumptions about the data. This does not the least apply for temp tables that are shared between stored procedures. Also, defining primary keys for your temp tables can avoid performance issues when you start to join them."

     

    The two applications are different. Dummy in this example is used as a table valued parameter and not a varchar parameter.

    I see no use for the declaration of the Dummy parameter in case of the op - just some bad developer practice or like Gail said - somebody was smoking something.

    It could also be a holdover from an Oracle conversion where dummy tables are used rampantly but there isn't something that does the same thing by default in SQL so the developer built something to resemble the oracle process.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events