July 29, 2011 at 3:06 am
in order to find the total no of records present in the table currently, we are using SELECT COUNT(*) FROM table_name;
is there any alternative for this?
Is there any system table which internally maintains this detail for all tables.
if so, we can make use of that and get the record count fastly.
Thanks,
Pandeeswaran
July 29, 2011 at 3:54 am
Try This:
SELECT OBJECT_NAME(OBJECT_ID) TableName, st.row_count
FROM sys.dm_db_partition_stats st
WHERE OBJECT_NAME(OBJECT_ID) = N'TableName'
Vishal Gajjar
http://SqlAndMe.com
July 29, 2011 at 3:58 am
July 29, 2011 at 4:20 am
Vishal.Gajjar (7/29/2011)
Try This:
SELECT OBJECT_NAME(OBJECT_ID) TableName, st.row_count
FROM sys.dm_db_partition_stats st
WHERE OBJECT_NAME(OBJECT_ID) = N'TableName'
Will it give the exact result similar to COUNT(*) or it depends on the last analyzed time?
thanks.
Thanks,
Pandeeswaran
July 29, 2011 at 4:30 am
http://www.sqlservercentral.com/articles/T-SQL/67624/
Heres and article on how to perfrom fast rowcounts
July 29, 2011 at 5:17 am
it will return accurate results, it is a dynamic management view.
Vishal Gajjar
http://SqlAndMe.com
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply