Home Forums Programming General Running Multiple instance of the same stored procedure RE: Running Multiple instance of the same stored procedure

  • Once you create a temp table, it is available to any code further down that procedure, and to any procedures that the initial procedure may call after the table has been created. So, this is the design you would be shooting for.

    CREATE PROCEDURE SP_FillTable As

    IF OBJECT_ID('tempdb..#AreaReadings') IS NULL CREATE TABLE #AreaReadings(col1 int)

    INSERT INTO #AreaReadings

    select ...

    GO

    CREATE PROCEDURE sp_CalculateResults AS

    CREATE TABLE #AreaReadings (col1 int)

    execute sp_FillTable

    select * from #AreaReadings

    GO

    I'd be more worried about that

    The whole process takes about 3min to execute.

    part.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2