In this article, we will see how to get all the table names in the SQL Server database. We can easily find out all the tables in the SQL server database using below two methods.
SQL Query :
First, select the database using
USE (as shown below) where you want to find out the table names.
USE Sample; // Sample is database name SELECT TABLE_NAME FROM information_schema.tables WHERE table_type = 'base table'
In the above SQL Query, we select Table_Name Field from the system table called Information_Scheme.table and filter by table_typle as 'base table' to get the table details from selected database "Sample".
You can also use sys.tables to get all table names from the selected database as shown in the following SQL query :
USE Sample; SELECT name FROM sys.tables;
In this article, we have learned using how to get all the table's names in the SQL Server database using a query.