Bagikan melalui


Skrip Informasi Distributor dan Penerbit

Berlaku untuk: SQL Server Azure SQL Managed Instance

Skrip ini menggunakan tabel sistem dan prosedur tersimpan replikasi untuk menjawab pertanyaan yang umum ditanyakan tentang objek di Distributor dan Penerbit. Skrip dapat digunakan "apa adanya" dan juga dapat memberikan dasar untuk skrip yang disesuaikan. Skrip mungkin memerlukan dua modifikasi untuk dijalankan di lingkungan Anda:

  • Ubah baris use AdventureWorks2022 untuk menggunakan nama database publikasi Anda.

  • Hapus komentar (--) dari baris exec sp_helparticle @publication='<PublicationName>' dan ganti <PublicationName> dengan nama publikasi.

--********** Execute at the Distributor in the master database **********--  
  
USE master;  
go  
  
--Is the current server a Distributor?  
--Is the distribution database installed?  
--Are there other Publishers using this Distributor?  
EXEC sp_get_distributor  
  
--Is the current server a Distributor?  
SELECT is_distributor FROM sys.servers WHERE name='repl_distributor' AND data_source=@@servername;  
  
--Which databases on the Distributor are distribution databases?  
SELECT name FROM sys.databases WHERE is_distributor = 1  
  
--What are the Distributor and distribution database properties?  
EXEC sp_helpdistributor;  
EXEC sp_helpdistributiondb;  
EXEC sp_helpdistpublisher;  
  
--********** Execute at the Publisher in the master database **********--  
  
--Which databases are published for replication and what type of replication?  
EXEC sp_helpreplicationdboption;  
  
--Which databases are published using snapshot replication or transactional replication?  
SELECT name as tran_published_db FROM sys.databases WHERE is_published = 1;  
--Which databases are published using merge replication?  
SELECT name as merge_published_db FROM sys.databases WHERE is_merge_published = 1;  
  
--What are the properties for Subscribers that subscribe to publications at this Publisher?  
EXEC sp_helpsubscriberinfo;  
  
--********** Execute at the Publisher in the publication database **********--  
  
USE AdventureWorks2022;  
go  
  
--What are the snapshot and transactional publications in this database?   
EXEC sp_helppublication;  
--What are the articles in snapshot and transactional publications in this database?  
--REMOVE COMMENTS FROM NEXT LINE AND REPLACE <PublicationName> with the name of a publication  
--EXEC sp_helparticle @publication='<PublicationName>';  
  
--What are the merge publications in this database?   
EXEC sp_helpmergepublication;  
--What are the articles in merge publications in this database?  
EXEC sp_helpmergearticle; -- to return information on articles for a single publication, specify @publication='<PublicationName>'  
  
--Which objects in the database are published?  
SELECT name AS published_object, schema_id, is_published AS is_tran_published, is_merge_published, is_schema_published  
FROM sys.tables WHERE is_published = 1 or is_merge_published = 1 or is_schema_published = 1  
UNION  
SELECT name AS published_object, schema_id, 0, 0, is_schema_published  
FROM sys.procedures WHERE is_schema_published = 1  
UNION  
SELECT name AS published_object, schema_id, 0, 0, is_schema_published  
FROM sys.views WHERE is_schema_published = 1;  
  
--Which columns are published in snapshot or transactional publications in this database?  
SELECT object_name(object_id) AS tran_published_table, name AS published_column FROM sys.columns WHERE is_replicated = 1;  
  
--Which columns are published in merge publications in this database?  
SELECT object_name(object_id) AS merge_published_table, name AS published_column FROM sys.columns WHERE is_merge_published = 1;  

Lihat Juga

Tanya Jawab Umum untuk Administrator Replikasi
sp_get_distributor (T-SQL)
sp_helparticle (T-SQL)
sp_helpdistributiondb (T-SQL)
sp_helpdistpublisher (T-SQL)
sp_helpdistributor (T-SQL)
sp_helpmergearticle (T-SQL)
sp_helpmergepublication (T-SQL)
sp_helppublication (T-SQL)
sp_helpreplicationdboption (T-SQL)
sp_helpsubscriberinfo (T-SQL)
sys.columns (Transact-SQL)
sys.databases (T-SQL)
sys.procedures (Transact-SQL)
sys.servers (Transact-SQL)
sys.tables (Transact-SQL)
sys.views (Transact-SQL)