Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 754847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:03:40+00:00 2026-05-14T15:03:40+00:00

We are running MS SQL 2005 and we have been experiencing a very peculiar

  • 0

We are running MS SQL 2005 and we have been experiencing a very peculiar problem the past few days.

I have two procs, one that creates an hourly report of data. And another that calls it, puts its results in a temp table, and does some aggregations, and returns a summary.

They work fine…until the next morning.

The next morning, suddenly the calling report, complains about an invalid column name.

The fix, is simply a recompile of the calling proc, and all works well again.

How can this happen? It’s happened three nights in a row since moving these procs into production.

EDIT: It appears, that it’s not a recompile that is needed of the caller (summary) proc. I was just able to fix the problem by executing the callee (hourly) proc. Then executing the summary proc. This makes less sense than before.

EDIT2:
The hourly proc is rather large, and I’m not posting it here in it’s entirety. But, at the end, it does a SELECT INTO, then conditionally, returns the appropriate result(s) from the created temp table.

Select      [large column list]
    into    #tmpResults
    From    #DailySales8
    Where   datepart(hour,RowStartTime) >= @StartHour
    and datepart(hour,RowStartTime) < @EndHour
    and datepart(hour, RowStartTime) <= @LastHour

IF @UntilHour IS NOT NULL 
    AND EXISTS (SELECT * FROM #tmpResults WHERE datepart(hour, RowEndTime) = @UntilHour) BEGIN
        SELECT      * 
            FROM    #tmpResults
            WHERE   datepart(hour, RowEndTime) = @UntilHour
END ELSE IF @JustLastFullHour = 1 BEGIN
        DECLARE @MaxHour INT
        SELECT @MaxHour = max(datepart(hour, RowEndTime)) FROM #tmpResults

        IF @LastHour > 24 SELECT @LastHour = @MaxHour

        SELECT      * 
            FROM    #tmpResults
            WHERE   datepart(hour, RowEndTime) = @LastHour

        IF @@ROWCOUNT = 0 BEGIN
            SELECT      * 
                FROM    #tmpResults
                WHERE   datepart(hour, RowEndTime) = @MaxHour
        END
END ELSE BEGIN
        SELECT * FROM #tmpResults
END

Then it drops all temp tables and ends.

The caller (Summary)

First creates a temp table #tmpTodaySales to store the results, the column list DOES MATCH the definition of #tmpResults in the other proc. Then it ends up calling the hourly proc a couple times

    INSERT #tmpTodaysSales
        EXEC HourlyProc @LocationCode, @ReportDate, null, 1


    INSERT #tmpTodaysSales
        EXEC HourlyProc @LocationCode, @LastWeekReportDate, @LastHour, 0

I believe it is these calls that fail. But recompiling the proc, or executing the hourly procedure outside of this, and then calling the summary proc fixes the problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:03:40+00:00Added an answer on May 14, 2026 at 3:03 pm

    Two questions:

    Does the schema of #DailySales8 vary at all? Does it have any direct/indirect dependence on the date of execution, or on any of the parameters supplied to HourlyProc?

    Which execution of INSERT #tmpTodaysSales EXEC HourlyProc ... in the summary fails – first or second?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been running SQL Server 2005 Express Management Studio (SSMSE), and I now
I have a very long-running stored procedure in SQL Server 2005 that I'm trying
I have a long-running SQL Server 2005 query that I have been hoping to
We have a Windows machine running SQL Server 2005, and we need to be
We have SQL Server 2005 running on Win2003/64, and we push it hard. We
I have an application that is currently running against a 32-bit SQL Server 2005
Recently, I've started having a problem with my SQL Server 2005 client running on
I have a database running on MS SQL Server 2005 and an ASP.NET 3.5
I asked a question a few days ago ( Access to SQL Server 2005
We're running SQL 2005 standard SP2 on a 4cpu box. Suddenly it crashdumps, after

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.