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

Afroz picture Afroz · Jun 5, 2013 · Viewed 8.2k times · Source

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')

Answer

Afroz picture Afroz · Jun 5, 2013

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