Skip to content

Instantly share code, notes, and snippets.

@pregress
Created September 3, 2020 07:14
Show Gist options
  • Save pregress/623dd74051dd11ffd44348fe22c83a52 to your computer and use it in GitHub Desktop.
Save pregress/623dd74051dd11ffd44348fe22c83a52 to your computer and use it in GitHub Desktop.
SELECT SUM(p.rows) as [cnt]
FROM sys.partitions AS p
INNER JOIN sys.tables AS t ON p.[object_id] = t.[object_id]
WHERE p.index_id = 1 /* clustered index */
AND t.name = N'tablename'AND t.schema_id = schema_id('dbo');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment