Table and row count

Hi:

 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.

Thanks
LuckyLucksAsked:
Who is Participating?
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:
SELECT DISTINCT
        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] ,
        [Table];
0
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 )

http://www.brentozar.com/archive/2014/02/count-number-rows-table-sql-server/

http://beyondrelational.com/modules/2/blogs/77/posts/11297/measuring-the-number-of-rows-in-a-table-are-there-any-alternatives-to-count.aspx
0

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?
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.