This blog is having some useful commands we use for replication and troubleshooting.
>>Some useful commands and stored procedures
How it works:
Log reader agent stores the command and transaction into following tables.
eg. SELECT * FROM distribution.dbo.MSrepl_Commands
--- commands for all transactions for replication for seqno or all
WHERE xact_seqno = 0x00001C030000F4540018
eg. SELECT * FROM distribution.dbo.MSrepl_Transactions
-- -- transactions for particular seqno or all
WHERE xact_seqno= 0x00001C030000F4540018
3. sp_browsereplcmds stored procedure
And we can see sql script/text using sp_browsereplcmds stored procedure.
Eg. sp_browsereplcmds @xact_seqno_start = '0x00001C030000F4540018', -- returns all/seqno info (sql query) on replication
@xact_seqno_end = '0x00001C030000F4540018'
It stores all the transactions (sql script) on distribution which will distribute to subscriber. and once these transaction delivers to subscriber. “Distribution cleanup job” will clean these tables.
select * from distribution.dbo.MSrepl_errors ---returns errors for replication.
select * from distribution.dbo.msdistribution_history ---- job history
select * from distribution.dbo.MSarticles ---- give info about replication articles
select * from publisher.dbo.sysarticles ---- give info about replication articles
Also transaction replication takes article up to 255 columns limit.
Run this at subscriber to get information about replication includes publisher.
exec sp_MSenumsubscriptions 'both'
SELECT * FROM MSreplication_subscriptions
To remove the Replication:
* Once we found on our dev server, the distribution database was not properly deleted and we could not able to work on it.
We wanted to drop the distribution but system was not allowing us... entry was there in this table.
select * from distribution.dbo.msdistribution_agents --- distributor agent info
To remove the unwanted Replication follow the below link:
I mostly use the following commands for the same:
exec master.dbo.sp_dropdistributor @no_checks = 1
Today I was working on Transaction replication on Sql server 2000 sp3a... found very weird thing, I removed replication with above commands no replication were exists but when tring to drop the table was getting below error:
Server: Msg 3724, Level 16, State 2, Line 1
Cannot drop the table 'test1' because it is used for replication.
I searched a lot but could not find much information, also tried to detach the db and attached on different server but no luckL.
Finally got the solution as, on "sysobjects" table and "replinfo" column was 1
So as sysobjects is a system table (*careful while making any changes at system table) it requires advance sp_confige option =1 for updating system tables.
update sysobjects set replinfo=0 where replinfo=1
Thanx to Vyas for the great article.
I will blog more about useful commands related to replication.