Sql-server – Get the list of all Tables, Views, Stored procedures that are not added in a publication for replication

replicationsql server

How do I get the list of all Tables, Views, Stored procedures that are NOT added in a publication for replication?

Best Answer

For Snapshot and Transactional:

SELECT
    name 
FROM sysobjects WITH (NOLOCK) 
WHERE ((xtype = 'U') OR (xtype = 'V') OR (xtype = 'P')) AND 
    category <> 2 AND 
    name NOT IN (SELECT DISTINCT object_name(OBJID) FROM sysarticles)

For Merge:

SELECT
    name 
FROM sysobjects WITH (NOLOCK) 
WHERE ((xtype = 'U') OR (xtype = 'V') OR (xtype = 'P')) AND 
    category <> 2 AND 
    name NOT IN (SELECT DISTINCT object_name(OBJID) FROM sysmergearticles)