1.查询数据库所有表
SELECT '''' + s.name + ''',' FROM sysobjects s WHERE s.xtype = 'U' ORDER BY s.name
2.根据第一查询所有表,查询表数据量
SELECT o.name,
ddps.row_count
FROM sys.indexes AS i
INNER JOIN sys.objects AS o
ON i.OBJECT_ID = o.OBJECT_ID
INNER JOIN sys.dm_db_partition_stats AS ddps
ON i.OBJECT_ID = ddps.OBJECT_ID
AND i.index_id = ddps.index_id
WHERE i.index_id < 2
AND o.is_ms_shipped = 0
AND o.name IN ('表1', '表2', '表3', '表4', '表5', '表6',)
ORDER BY
o.name,
ddps.row_count