how to insert from Stored Procedures to #temp table

  • i need help to insert to #temp table from Stored Procedures

    like this

    ----------------------

    1 )to insert to  the #temp table from Stored Procedures(10 Fields)

    2) after make a select (filtering the #tamp table)

    3) insert to the main table (only after  filtering the #tamp table)

    4 ) delete the #tamp table

    ----------------------------

    and all in one Stored Procedures !!!

    1.  insert
    2. select
    3. insert
    4. delete

    -------------------------------------

    thnks ilan

     

  • Could you give an example?

    I'm not sure what exactly you want to do.

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

  • Do you mean this

    CREATE TABLE #temp (col1 int, col2 int, ...)

    INSERT INTO #temp

    EXECUTE procname

    INSERT INTO #temp

    EXECUTE anotherproc

    INSERT INTO [maintable]

    SELECT col1, col2, ...

    FROM #temp

    WHERE [some criteria]

    DROP TABLE #temp

    Remember the #temp table must the correct number and type of columns to match what the procs produce.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Why dont you use ##temp instead #temp ?

    ##temp is a global temporary table, and you can reference it from any connection, with the name you create it.

     

    Alejandro Claver

    Cali, Colombia

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

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