How to get all table names of a particular database using TSQL
By Tan Lee Published on Feb 16, 2024 535
This example shows you the best way to get the names of all of the tables in a specific database on SQL Server or My SQL
Open the SQL editor, and type this query
For SQL Server:
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_CATALOG='YourDatabaseName'
For MySQL:
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA='YourDatabaseName'
You can use the following query to select all of the tables in the database named DbName
USE DbName SELECT * FROM sys.Tables
Update for the latest version of MSSQL Server 17.7
USE DbName SELECT name FROM sys.Tables WHERE type_desc = 'USER_TABLE'
- How to Download ODBC Driver for SQL Server
- How to Download SQL Server Management Studio (SSMS) Versions
- How to Query JSON in SQL Server
- How to modify JSON in SQL Server
- How to set time to 00:00:00 with GETDATE() in SQL
- How to find all the dependencies of a table in SQL Server
- How to Find Objects Referencing a Table in SQL Server
- Case sensitivity in SQL Server
Categories
Popular Posts
11 Things You Didn't Know About Cloudflare
Dec 19, 2024
Toolbox Admin Responsive Tailwind CSS Admin Template
Nov 20, 2024
Portal HTML Bootstrap
Nov 13, 2024
Focus Admin Dashboard Template
Nov 18, 2024