查询数据库符合要求的表
查询数据库中满足表记录数大于10000的所有表
查询的结果是满足要求的表 不是select * from tablename
[解决办法]
DECLARE @sql NVARCHAR(max)SET @sql=' DECLARE @table TABLE(table_name VARCHAR(100),cnt INT) INSERT INTO @table 'SELECT @sql=@sql+N' SELECT TABLE_NAME='''+TABLE_SCHEMA+N'.'+TABLE_NAME+''',COUNT(1) as cnt FROM '+TABLE_SCHEMA+N'.'+TABLE_NAME+N' union all' FROM INFORMATION_SCHEMA.tablesWHERE TABLE_TYPE='BASE TABLE' SET @sql=LEFT(@sql,LEN(@sql)-LEN('union all'))SET @sql=@sql+N'select * from @table where cnt> 10000 'EXEC(@sql)
[解决办法]
SELECT OBJECT_NAME(Id) FROM sysindexesWHERE indid < 2 AND rows > 10000