Created
June 9, 2020 13:48
-
-
Save Warrenn/795f0219b28897e454a372d5f1e3f1f5 to your computer and use it in GitHub Desktop.
fast count of rows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT @count = SUM(p.rows) | |
FROM sys.partitions AS p | |
INNER JOIN sys.tables AS t | |
ON p.[object_id] = t.[object_id] | |
INNER JOIN sys.schemas AS s | |
ON t.[schema_id] = s.[schema_id] | |
WHERE p.index_id IN (0,1) -- heap or clustered index | |
AND t.name = N'tablename' | |
AND s.name = N'dbo'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment