1 DECLARE @TableName varchar(255);
 2 CREATE TABLE #GetRecordingTempTable([id] [INT] IDENTITY(1,1NOT NULL[TableName] varchar(255NOT NULL[RecordingCount] INT);
 3 DECLARE Table_Cursor CURSOR FOR SELECT [name] FROM sysobjects WHERE xtype='U';
 4 OPEN Table_Cursor;
 5 FETCH NEXT FROM Table_Cursor INTO @TableName;
 6 WHILE(@@FETCH_STATUS=0)
 7 BEGIN
 8 EXEC('INSERT INTO #GetRecordingTempTable ([TableName],[RecordingCount]) SELECT '''+@TableName+''', COUNT(0) FROM ['+@TableName+'];');
 9 FETCH NEXT FROM   Table_Cursor INTO @TableName;
10 END
11 CLOSE Table_Cursor;
12 DEALLOCATE Table_Cursor;
13 SELECT [TableName] AS [表名称],[RecordingCount] AS [总记录数] FROM #GetRecordingTempTable ORDER BY [RecordingCount] DESC;
14 DROP TABLE #GetRecordingTempTable;
15 GO

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-02
  • 2021-08-24
  • 2022-12-23
  • 2021-11-22
  • 2022-12-23
猜你喜欢
  • 2021-08-21
  • 2021-10-02
  • 2022-12-23
  • 2021-12-03
  • 2021-09-19
  • 2022-12-23
相关资源
相似解决方案