record count

-- Microsoft SQL Server 2005 and later
-- record count
SELECT SUM(p.row_count)
FROM sys.schemas s
INNER
JOIN sys.tables t
  ON s.schema_id = t.schema_id
INNER
JOIN sys.dm_db_partition_stats p
  ON t.object_id = p.object_id
WHERE s.name = N'dbo'
  AND t.name = N'table_name'
  AND p.index_id < 2


-- Microsoft SQL Server 2000
-- record count
-- sysindexes is updated in real time
SELECT rows 
FROM sysindexes 
WHERE id = OBJECT_ID('<table>') AND indid < 2
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s