Find tables without relationships - Loner Tables - in SQL Server database

This query listed tables that have no foreign keys, meaning they are not referencing any table or are not on the "many" side of FK.

Query below lists something a little different - tables that are not referencing and are not referenced by other tables. Something I called Loner Tables. This diagram illustrates the concept:

Learn more about Loner Tables

Check out this summary article of FK queries for SQL Server.


select 'No FKs >-' refs, as [table],
    '>- no FKs' fks
    (select schema_name(tab.schema_id) + '.' + as tab,
        count( as fk_cnt
    from sys.tables as tab
        left join sys.foreign_keys as fk
            on tab.object_id = fk.parent_object_id
    group by schema_name(tab.schema_id), fks
    inner join 
    (select schema_name(tab.schema_id) + '.' + as tab,
        count( ref_cnt
    from sys.tables as tab
        left join sys.foreign_keys as fk
            on tab.object_id = fk.referenced_object_id
    group by schema_name(tab.schema_id), refs
    on =
where fks.fk_cnt + refs.ref_cnt = 0


  • refs - icon symbolizing lack of references by foregin key constraints
  • table - name of the table with schema name
  • fks - icon symbolizing lack of foregin key constraints


  • One row represents one table
  • Scope of rows: tables that are not related (not refererencing and not being referenced with foreign key constraints) with any table
  • Ordered by schema table name

Sample results

List of Loner Tables in AdventureWorks:

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