USE DatabaseName
GO
SELECT rowcnt
FROM dbo.sysindexes
WHERE OBJECT_NAME(id) = 'TableName'
GO
-- Returns
330013
A count of the table results in the following;
USE DatabaseName
GO
SELECT COUNT(1) AS CNT
FROM dbo.TableName
GO
-- Returns
331882
To update the sysindexes table with the correct row counts, we run the following DBCC;
USE DatabaseName
GO
DBCC UPDATEUSAGE(0) WITH COUNT_ROWS;
GO
Now when we run our queries again, we get the following;
USE DatabaseName
GO
SELECT rowcnt
FROM dbo.sysindexes
WHERE OBJECT_NAME(id) = 'TableName '
GO
SELECT COUNT(1) AS CNT
FROM dbo.TableName
GO
-- Returns
331882
-- Returns
331882