Get Table Names from SQL Server Database

In this article, we will show you how to write a SQL query to Get Table Names from SQL Server Database with examples.

Get Table Names from SQL Server Database Example 1

For this get list of table names in Sql Server database demonstration, we are using the AdventureWorks DW database. In this SQL example query, we will show you how to Get List of Table names in a database.

-- Query to Get SQL Server Database Table Names
USE [AdventureWorksDW2014]
GO
SELECT *
FROM INFORMATION_SCHEMA.TABLES
Get Table Names from SQL Server Database 1

You can also use Where clause along with information_schema tables to restrict the list of table names in SQL Server.

-- Query to Get SQL Server Database Table Names
USE [AdventureWorksDW2014]
GO
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
Get Table Names from SQL Server Database 2

Get Table Names in a Database Example 2

In this example, we are using the sys.objects table to find a list of table names in SQL Server.

-- Query to Get SQL Server Database Table Names
USE [AdventureWorksDW2014]
GO
SELECT name, create_date, modify_date FROM sys.objects
WHERE type_desc = 'USER_TABLE'
-- WHERE type = 'U'
Get Table Names from SQL Server Database 3

We are using the sys.tables table to find the list of table names.

-- Query to Get SQL Server Database Table Names
USE [AdventureWorksDW2014]
GO
SELECT * FROM sys.tables
Get Table Names from SQL Server Database 4

You can also select the required columns from the sys.tables using the below-shown query. By this, you can see the required columns, such as Table Name, Created Date, and Table Modified Date, etc.

-- Query to Get SQL Server Database Table Names
USE [AdventureWorksDW2014]
GO
SELECT name, create_date, modify_date FROM sys.tables
Get Table Names from SQL Server Database 5