MSSQL 查詢Table資料筆數(非即時)
有時TABLE資料筆數太多, 無法查詢即時筆數, 可以透過下列語法, 查詢SQL Server記錄的筆數, 參考用, 非即時資料
select * from ( SELECT SCHEMA_NAME(A.schema_id) + '.' + A.Name TableName, AVG(B.rows) AS 'RowCount1' FROM sys.objects A INNER JOIN sys.partitions B ON A.object_id = B.object_id WHERE A.type = 'U' GROUP BY A.schema_id, A.Name ) AA where AA.TableName='dbo.'+'<table-name>' order by AA.RowCount1 desc
留言
張貼留言