[MS SQL] Select all tables for a given schema - DevDummy

Latest

Views | Thoughts | Concepts | Techniques

Wednesday, July 22, 2020

[MS SQL] Select all tables for a given schema

While we are working with SQL Server, it is often required to see the tables under the different schemas. 

You can still do that via SQL Server Management Studio. But if you need to join results for several schemas or do some manipulations, the query can be very useful.



The following query will list all the tables in the given schema,


SELECT s.name as 'Schema Name', t.name as 'Table Name'
FROM SYS.tables t
INNER JOIN sys.schemas s
ON t.schema_id = s.schema_id
WHERE s.Name = 'ETL' ;

...

No comments:

Post a comment