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.

    Query

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

    Columns

    • database_name - database names

    Rows

    • 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.

    0
    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.
    Accept