Table and row count


 I am looking to find row count of every table/view and print out as table/view name and the row count. How can I do this in MS SQL 2012 R2? If you can tell me how to segregate for system and non - system, that would be best.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aneesh RetnakaranDatabase AdministratorCommented:
        OBJECT_SCHEMA_NAME(p.object_id) AS [Schema] ,
        OBJECT_NAME(p.object_id) AS [Table] ,
        OBJECTPROPERTY(p.object_id, 'IsUserTable') IsUserTable ,
        p.rows AS [Row Count]
 FROM   sys.partitions p
 INNER JOIN sys.indexes i ON p.object_id=i.object_id
                             AND p.index_id=i.index_id
--WHERE OBJECT_SCHEMA_NAME(p.object_id) != 'sys'
ORDER BY [Schema] ,
Anoo S PillaiCommented:
If you have the patience to read , you will get at least 3 to 4 ways to do it  and a comparison between them from the following links ( not copying any scripts here )

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vitor MontalvãoMSSQL Senior EngineerCommented:
LuckyLucks, do you still need help with this question?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.