Monday, September 9, 2024

How do I list all tables in a specific database?

 You can use the following query to list all tables in the current database:

SELECT TABLE_NAME 

FROM INFORMATION_SCHEMA.TABLES

WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_CATALOG = 'YourDatabaseName';

This query returns the names of all base tables in the specified database.