SQL Server does not have ROW_NUMBER , but just Oracle. Using:
SELECT COUNT(primary_key) FROM table
Where primary key column of your table.
Since it is the primary key, it is already indexed, so SQL can calculate it without scanning the entire table (it more accurately uses a clustered index, which is much faster than a full table scan)
You can also use the sys.indexes schema, but its inaccuracy, and you need database access permissions to access, and the user of your application database should not have grants in this schema
MestreLion
source share