How to get all table names of a particular database using TSQL
By FoxLearn 2/16/2024 4:51:23 AM 90
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 export data to .csv file
- How to Read Excel file and Import data from Excel to SQL Server in C#
- How to Create a backup SQL Server in C#
- How to Search data from Database in C#
- How to rename a column name in SQL
- How to add primary key to existing table in SQL Server
- How to add index in SQL Server
- How to Download and Restore Northwind database to SQL Server
Categories
Popular Posts
C# Tutorial
07/20/2024
How to Download Microsoft SQL Server
06/22/2024
What Are RESTful Web Services?
02/19/2024
What is ARM architecture?
04/01/2024