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:
01326485
Views:
12
>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).
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform