Search code examples
sql-serversql-server-2008transactional-replication

T-SQL to find if a Database is Subscribed on the Subscriber in Transactional Replication


T-SQL to find if a Database is Subscribed on the Subscriber in Transactional Replication. I don't want to query Distribution for the details.

The following doesn't work.

SELECT is_subscribed FROM sys.databases

SELECT DATABASEPROPERTYEX('database', 'IsSubscribed')

Solution

  • So far this is the best way I found but I am not sure if this works in Non-Transactional Replication.

    SELECT COALESCE(OBJECTPROPERTY(OBJECT_ID('dbo.MSreplication_objects'), 'IsMSShipped'),0) AS IsSubscribed
    

    OR

    SELECT name
    FROM sys.databases
    WHERE OBJECT_ID(name+'.dbo.MSreplication_objects') IS NOT NULL