在CSDN的帖子中有人问过这个问题,这里做个解答。
直观上查询所有用户表,获取count即可,但是这样很糟糕。
declare @N int set @N=10000
--通过查询索引表的聚集索引查询 (indid=1,这种是体现数据是以聚集索引方式存储体现的查询)
select object_name(id),rowcnt from sysindexes where rowcnt>=@N and indid=1 and objectproperty(id,'isusertable')=1
--通过查询索引表的无聚集索引查询 (indid=0,这种是体现数据是以数据堆方式存储体现的查询,无聚集索引的表)
select object_name(id),rowcnt from sysindexes where rowcnt>=@N and indid=0 and objectproperty(id,'isusertable')=1
有人问indid是什么意思,
一张具有实际应用意义的表,都应该有个聚集索引(个人觉得无聚集索引的表意义不大,呵呵,如果实在都要查就
select object_name(id),rowcnt from sysindexes where rowcnt>=@N and indid<=1 and objectproperty(id,'isusertable')=1 即可),非聚集索引则不一定
必须。
indid=1 查询的就是根据聚集索引键值来查询sysindexs,也就是说不存在聚集索引的表&#x