Tested on Sql Server 2008 and 2008 R2.
Code Snippet
- select SCHEMA_NAME(sys.tables.schema_id) as [Schema], sys.tables.name as [Table], sys.sysindexes.rowcnt as [Cnt]
- from sys.indexes
- join sys.sysindexes
- on sysindexes.id = sys.indexes.object_id
- and sysindexes.indid = sys.indexes.index_id
- join sys.tables
- on sys.tables.object_id = sys.sysindexes.id
- where is_primary_key = 1
- and sys.tables.type_desc = 'USER_TABLE'
- order by [Schema], [Table]
It is simple, isn’t it?
No comments:
Post a Comment