Could not locate statistics

  • I've inherited a new DB and had a question on a slow query. So I wanted to check the statistics on a table

    sp_helpdb wsMWC

    Auto update of stats is on

    SELECT name AS stats_name,

    STATS_DATE(object_id, stats_id) AS statistics_update_date

    FROM sys.stats

    WHERE object_id = OBJECT_ID('[dbo].[tblJob]');

    GO

    Everything looks like fine; it looks like all indexes were recently updated

    Then I tried

    DBCC show_statistics ("dbo.tblWorkOrder", "PK_tblJob") WITH STAT_HEADER

    and I get the error:

    Msg 2767, Level 16, State 1, Line 1

    Could not locate statistics '[PK_tblJob]' in the system catalogs.

    What am I not understanding here?

  • I'm not accustomed to quotes around the stat name. Try it without those?

    Edit: Never mind. Just tried it and it worked.

    Are you sure you don't have a typo in the stat name?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • I tried with single, double and no quotes around the stat name with same result.

    The idea about a typo is a good one; so I dragged and dropped within SSMS. The only difference is that it puts [] around the name. But still says it can't locate the statistitics 'PK_tblJob'.

  • So, the table is "tblJob" in the first query (in the OBJECT_ID function-call), but it's "tblWorkOrder" in the second query. Is that intentional?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • GSquared (9/12/2012)


    So, the table is "tblJob" in the first query (in the OBJECT_ID function-call), but it's "tblWorkOrder" in the second query. Is that intentional?

    Doh!!! Thank you -- I needed another pair of eyes. Sorry, I was mixing two table. So, no surprise SQL Server couldn't find the stats from one table on a different table.

    Thanks,

    Rob

  • Murphy hates us. 🙂

    You're welcome.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 6 posts - 1 through 5 (of 5 total)

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