Click here to Skip to main content
Click here to Skip to main content
Alternative Tip
Go to top

Record Count of Tables in SQL Server

, 16 Aug 2011
Rate this:
Please Sign up or sign in to vote.
Sometimes it is necessary to have the schema name included as well. I concatenate with the table name for my convenience, but it is not vital to do so.SELECT sys.sysindexes.rows, sys.schemas.name + '.' + sys.objects.nameFROM sys.objectsINNER JOIN sys.schemasON ...

Sometimes it is necessary to have the schema name included as well. I concatenate with the table name for my convenience, but it is not vital to do so.

SELECT        sys.sysindexes.rows, sys.schemas.name + '.' + sys.objects.name
FROM          sys.objects
INNER JOIN    sys.schemas
ON            sys.objects.schema_id = sys.schemas.schema_id
INNER JOIN    sys.sysindexes
ON            sys.objects.object_id = sys.sysindexes.id
WHERE         sys.objects.type = 'u'
AND           sys.objects.name <> 'dtproperties'
AND           sys.objects.name <> 'sysdiagrams'
AND           sys.sysindexes.indid < 2

Also get rid of a couple of tables which we don't need to see in the count.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Graham Cottle
Software Developer (Senior)
United Kingdom United Kingdom
I have been developing applications for almost 30 years - started with early versions of Basic on the Sinclair ZX80, moving up via UK101 and Amstrad to PC. Played with Assembly as well. First big application was for a complete test set, which was written using QuickBasic (all I had available to me). Moved on to a bit of C and C++ (never really got to grips with them) and then 11 years ago, got into Visual Basic/SQL Server and HTML. Moved onto .NET and then in the last few years changed across to C# when the job market indicated that it would be better.
Have now developed quite a few ASP.NET Applications, and along the way have played with WPF, Silverlight and am currently working on an MVC based application.
Follow on   Twitter

Comments and Discussions

 
GeneralReason for my vote of 5 I was just about to write up this al... PinmemberJohn Kasra13-Sep-11 12:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140905.1 | Last Updated 16 Aug 2011
Article Copyright 2011 by Graham Cottle
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid