Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 newbie with mutliple table count

Author  Topic 

burtondav
Starting Member

1 Post

Posted - 2011-04-25 : 15:45:28
I would like to just count the number of records in several tables.
For instance:
Select Count(*) from Asset.

Is there a way to write ONE select and count records from multiple tables?

Burtondav

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-04-25 : 15:53:10
If you have no WHERE conditions:

SELECT OBJECT_NAME(OBJECT_ID) tbl, rows
FROM sys.partitions
WHERE index_id<2
AND OBJECT_NAME(OBJECT_ID) IN ('myTable1', 'myTable2', 'myTable3')
Go to Top of Page
   

- Advertisement -