How to check if a Statistics is auto-created in a SQL Server 2000 DB using T-SQL?
- by The Shaper
Hi all. A while back I had to come up with a way to clean up all indexes and user-created statistics from some tables in a SQL Server 2005 database. After a few attempts it worked, but now I gotta have it working in SQL Server 2000 databases as well. For SQL Server 2005, I used
SELECT Name FROM sys.stats
WHERE object_id = object_id(@tableName)
AND auto_created = 0
to fetch Statistics that were user-created. However, SQL 2000 doesn't have a sys.stats table. I managed to fetch the indexes and statistics in a distinguishable way from the sysindexes table, but I just couldn't figure out what the sys.stats.auto_created match is for SQL 2000. Any pointers?
BTW: T-SQL please.