The Best Damn Visual Studio Add-In Ever

Get Table Row Count

22. May 2020 14:20 by Scott in Development, TSql  //  Tags: , ,   //   Comments (0)
/****** Script for SelectTopNRows command from SSMS  ******/

      use adeffx_data_master
  SELECT SCHEMA_NAME(schema_id) AS [SchemaName],
[Tables].name AS [TableName],
SUM([Partitions].[rows]) AS [TotalRowCount]
FROM sys.tables AS [Tables]
JOIN sys.partitions AS [Partitions]
ON [Tables].[object_id] = [Partitions].[object_id]
AND [Partitions].index_id IN ( 0, 1 )
WHERE [Tables].name = N'mid_group_id_map'
GROUP BY SCHEMA_NAME(schema_id), [Tables].name;