How to check if a Statistics is auto-created in a SQL Server 2000 DB using T-SQL?

Posted by The Shaper on Stack Overflow See other posts from Stack Overflow or by The Shaper
Published on 2010-02-11T12:40:51Z Indexed on 2010/04/03 10:43 UTC
Read the original article Hit count: 297

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server-2000