Find tables that are not used by any other object in Azure SQL database

Article for: SQL Server Oracle database

Query below lists all tables that are not referenced by any object .

Query

select schema_name(schema_id) as schema_name,
       name as table_name
from sys.tables tab
left join sys.sql_expression_dependencies dep
          on tab.object_id = dep.referenced_id
where dep.referenced_id is null
order by schema_name,
         table_name;

Columns

  • schema_name - schema name of the table
  • table_name - table name

Rows

  • One row represents one table that is not used by any other object
  • Scope of rows: all objects that are not used by any other object
  • Ordered by schema name and table name

Sample results

0
There are no comments. Click here to write the first comment.