Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking to see if a Statistic Exists
Message
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01326484
Message ID:
01326491
Views:
23
>>>I need a little help. I am trying to drop some statistics in SQL Server 2000 but I do not know how to check to see if it exists first to keep it from bombing. I tried sysobjects and sysindexes to no avail. I know that in SQL Server 2005 I can reference sys.stats, but this does not work in 2000. Any and all help will be greatly appreciated. Below is a sample of my SQL 2005 Code so you can see what I am trying to accomplish in SQL 2000.
>>>
>>>IF EXISTS(
>>> SELECT * FROM sys.stats
>>> WHERE object_id = object_id('OrderFL')
>>> AND name = '_dta_stat_514100872_4_7')
>>> DROP STATISTICS OrderFL._dta_stat_514100872_4_7
>>>
>>>GO
>>
>>Check sp_HelpStats in BOL.
>>
>>See also Re: Getting it all from Statistics Thread #1302337 Message #1302628 (and the whole thread).
>
>
>
>I did check that procedure before posting, it loops through the indexes on a given table and checks to see if those indexes has any statistics on them and then pulls the statistic names off of the indexes. I was looking for a more direct route.

Ok, looking into this problem right now and in the meantime I found http://www.code-magazine.com/Article.aspx?quickid=0301101 which may be useful.

Well, it's not in INFORMATION TABLE Views, http://www.sqlservercentral.com/articles/Administering/informationschemaviews/569/
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform