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

Article for: Azure SQL Database 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

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
0
There are no comments. Click here to write the first comment.