More efficient way of getting SQL table count.
I need to test these:
SQL 2005
SELECT OBJECT_NAME(P.object_id) AS [Name], P.* FROM sys.indexes I
INNER JOIN sys.partitions P ON P.object_id = I.object_id AND P.index_id = I.index_id
WHERE I.index_id < 2 AND P.object_id = OBJECT_ID(N'myTable')
Or
SQL 2008
SELECT 'MyTable' AS [Name], rows FROM sysindexes WHERE id = OBJECT_ID('MyTable') AND indid < 2
Ref: http://www.developmentalmadness.com/archive/2008/04/01/fast-rowcount-for-sql-2005.aspx
No comments:
Post a Comment