Passing temporary tables as parameters in SQL Server

  • hi,

    how to i pass a temporary table as a parameter to a stored procedure? I know you cant use a table variable to do that.

    Regds

     

     

  • Wouldn't it be better to generate the temporary table inside the stored procedure? That way you just pass the parameters needed to generate it along with any other parameters you need.

  • http://www.sommarskog.se/share_data.html

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • hi,

    all i'd like to know is whether it is possible to pass a temporary table as a parameter in a stored procedure???????????????????????????????????

    If so, how.

    Regds

     

     

     

  • TANSTAAFL.

    Short answer, no. But please read the article I referenced

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • As Frank told you, it is impossible to pass a table as a parameter to a stored proc.

    I personnally would use in your place a global temporary table (##Temp) which is available to all procs. The problem with the global temp table is that you have to manage it's lifecycle (from creation until destruction)



    Bye
    Gabor

  • I personnally would use in your place a global temporary table (##Temp) which is available to all procs. The problem with the global temp table is that you have to manage it's lifecycle (from creation until destruction)

    The other problem with global temp tables is that you can only have one instance of the named table at a time, so they don't work really well in multi-user applications.

    Mattie

  • You can use the table variable as a return from a UDF.  I have used this successfully in the past.

     

    Hope this helps!

     

    Don

Viewing 8 posts - 1 through 7 (of 7 total)

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