Quantcast
Channel: SQL Server Replication forum
Viewing all articles
Browse latest Browse all 4054

'sp_replicationdboption' cannot be executed within a transaction

$
0
0

I created a merge replication for a publisher (e.g. Pubisher1). Then I want to add a new aticle. Therefore, beside many other line of code (see "More Detail on above") within a db trigger I have line:

exec sp_replicationdboption @dbname = 'Publisher1',    @optname = 'merge publish', @value = 'true';

But I keep getting this error:

"The procedure 'sp_replicationdboption' cannot be executed within a transaction.
Msg 14013, Level 16, State 1, Procedure sp_MSrepl_refreshsubscriptions, Line 60
This database is not enabled for publication."

I am not sure what is going on?

********

More Detail on above:

What I am trying to do is to add an article (e.g. MyTable) to my publication (e.g. Pub1). I tried many different combination of options. My latest version of code is as follow:

________________________________________________________________________

exec sp_changemergepublication 'Pub1',@property='allow_anonymous',@value='true';
exec sp_changemergepublication 'Pub1', @property='allow_subscriber_initiated_snapshot', @value='true';

exec sp_changemergepublication 'Pub1', @property='allow_push', @value='true', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1;
            
---source of errors is these two lines (as stated above):           
exec sp_replicationdboption @dbname = 'Publisher1',    @optname = 'merge publish', @value = 'false';
exec sp_replicationdboption @dbname = 'Publisher1',    @optname = 'merge publish', @value = 'true';
            
EXEC sp_addmergearticle @publication = 'Pub1', @article = MyTable, @source_object = MyTable, @force_invalidate_snapshot = 1;
            
EXEC sp_mergearticlecolumn @publication = 'Pub1', @article = MyTable, @force_invalidate_snapshot = 1, @force_reinit_subscription = 1;
            
exec sp_link_publication @publisher = '7-PC' ,@publisher_db = 'Publisher1' , @publication =  'Pub1', @security_mode =  2, @login =  'sa' ,  @password = '*';
                    
exec sp_refreshsubscriptions 'Pub1';

exec sp_startpublication_snapshot 'Pub1'

_____________________________________________________________________

Can anyone help me on that? If you need even more details please let me know.

Thanks in advance



Viewing all articles
Browse latest Browse all 4054

Trending Articles