Get Table Names from SQL Server Database

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

Get Table Names from SQL Server Database Example

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

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

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

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.

USE [AdventureWorksDW2014]
GO
SELECT name, create_date, modify_date FROM sys.objects
WHERE type_desc = 'USER_TABLE'
-- WHERE type = 'U'
SELECT * FROM sys.objects
WHERE type = 'U'

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

USE [AdventureWorksDW2014]
GO
SELECT * FROM sys.tables
Using sys.tables 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, Table Modified Date, etc.

USE [AdventureWorksDW2014]
GO
SELECT name, create_date, modify_date FROM sys.tables
SELECT name, create_date, modify_date FROM sys.tables
Categories SQL