Find databases containing a particular table in Azure SQL Database

Rene Castro - Dataedo Team Rene Castro 2018-12-10

Table of Contents:

    Article for: Azure SQL Database SQL Server MySQL MariaDB Teradata

    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.

    By continuing to use our website, you consent to the use of cookies in accordance with our Privacy Policy (updated 28-04-2020).