Find databases containing a particular table in Azure SQL Database

Article for: SQL Server Teradata MySQL MariaDB

The query below finds all databases in Azure SQL Database instance containing a particular table (the table name must include its schema name). In this case the table is dbo.BuildVersion.


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


  • database_name - database names


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

Sample results

All databases containing the dbo.BuildVersion table.

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