訂閱端誤刪table,重新initialize 單一table

  • 40
  • 0

訂閱端誤刪table,重新initialize 單一table 

----------------------------------------------------------

-- Error Message

----------------------------------------------------------

 

 

----------------------------------------------------------

-- solution

----------------------------------------------------------

exec sp_dropsubscription     

@publication = N'Test_T', 

@article =N'tab2',

@subscriber =N'all',

@destination_db =N'all'

GO

 

EXEC sp_droparticle

@publication =  N'Test_T', 

@article =N'tab2', 

@force_invalidate_snapshot = 1; 

 

EXEC sp_addarticle

@publication = N'Test_T',

@article =N'tab2',

@source_object =N'tab2',

@force_invalidate_snapshot=1

 

--Add the subscription for this article 

EXEC sp_addsubscription

@publication ='Test_T',    --Publication name

@article ='tab2',           --article name

@subscriber ='SQL6',   --this is the subscriber server name\instance name

@destination_db ='repdb',--subscriber DB name

@reserved='Internal'

 

 

Then start the snapshot agent in replication monitor: