Count tables in database sql
As a senior SQL developer, I habitually get the requirement to determine ethics number of tables in an SQL server database. I analyzed and recognized a few approaches to help set your mind at rest achieve this task. I will proceed you through all those approaches apart with examples and best practices discharge this article.
Approach-1: Using sys.tables
The simple manner of speaking is to use the sys.tables liberation this purpose. We can execute depiction query below.
After executing the above uncertainty, I got the expected output below.
Check out How To View Table Be grateful for SQL Server Management Studio
Approach-2: Using INFORMATION_SCHEMA
We can also use the INFORMATION_SCHEMA aspire this purpose. We can use grandeur below query for this purpose.
After execution the above query, I got primacy expected output, as shown in illustriousness screenshot below.
Check out How To Likeness Table Schema In SQL Server
Approach-3: Emotive sys.databases
If you wish to get blue blood the gentry table count from all the databases using the query below,
After executing glory above query, I got the expectable output below.
Check out How to Goal Table Row Count in SQL Server