Find databases containing particular table in SQL Server database

Query below finds all databases in SQL Server instance containing particular table (table name must include schema name). In this case this table is dbo.version.


select [name] as [database_name] from sys.databases 
    case when state_desc = 'ONLINE' 
        then object_id(quotename([name]) + '.[dbo].[version]', 'U') 
    end is not null
order by 1


  • database_name - database names


  • One row represents one database
  • Scope of rows: all databases containing provided table schama and name
  • Ordered by database name

Sample results

All databases containing dbo.version table - that's how if search for Dataedo repositories.

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.