.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Programmatically changing a merge replication agent job

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :

Is there a supported way to change a merge replication agent job programmatically?  I know how I can do it in SSMS, but I would like to be able to script it.  I basically want to do the following:

  1. Change a replication job from uni-directional merge replication to bi-directional merge replication by removing "-EXCHANGETYPE 1" from the agent command
  2. Reinitialize the subscription tied to the replication job
  3. Wait some period of time for the merge replication job to start running again
  4. Change the replication job back from bi-direction merge replication to uni-directional merge replication by adding "-EXCHANGETYPE 1" from the agent command



View Complete Post

More Related Resource Links

Merge Replication: Fails using Replication.SaveProperties when changing Subscription Info

I'm trying to use SQL Server/Compact Framework 3 Merge Replication functionality and am running into a problem when calling Replication.SaveProperties (using c#). I was hoping to get some clarification on whether its my interpretation on how things should work vs a coding problem. Basically, the Merge Replication seems to work as I can sync information between my handheld and server databases.  However, I've created a form on my handheld so that the user can change some synchronication settings (e.g. Publication or Publisher Name) and then save it.  What I've noticed is : 1) You can NOT call Replication.SaveProperties until after a synchronization is performed (otherwise you get an error message).  Assuming this is so that it can create the "__sysMergeSubscriptions" table. Does this sound right? 2) If I then try to change the saved Subscriber information via another call to Replication.SaveProperties (e.g. change the Publication info), I then get an error message that says: The subscription was not found. Publisher, PublisherDatabase, or Publication  could be incorrect. Is this normal behavior?  Does this mean that you can you NOT change subscriber information; only add or drop it? Thanks,  Ed

SQL 2008. Merge replication. Snapshot agent. Access Denied

Windows Server 2008 Standard x64 SP1, SQL Server 2008 Enterprise Edition x64 SP1
Snapshot agent has read-write permissions to ReplData folder but cannot access local snapshot folder. How to resolve this error?

Error messages:
Source: mscorlib
Target Site: Void WinIOError(Int32, System.String)
Message: Access to the path 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\ReplData\unc\ServerName_DatabaseName_PublicationName\DateTime\' is denied.
Stack:    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, DirectorySecurity dirSecurity)
   at System.IO.Directory.CreateDirectory(String path, DirectorySecurity directorySecurity)
   at Microsoft.SqlServer.Replication.Utilities.CreateDirectoryWithExtendedErrorInformation(String directory)
   at Microsoft.SqlServer.Replication.Snapshot.SnapshotProvider.CreateSnapshotFolders()
   at Microsoft.SqlServer.Replication.Snapshot.MergeSnapshotProvider.CreateSnapshotFolders()
   at Microsoft.SqlServer.Replication.Snapshot.SqlServerSnapshotProvider.GenerateSnapshot()
   at Microsoft.SqlServer.Replication.SnapshotGenerationAgent.InternalRun()
   at Microsoft.SqlServer.Replication.AgentCore.Run() (Source: mscorlib, Error number: 0)
Get help: http

The best way to prevent an agent job to run in the middle of a merge replication.



I would like to configure a SQL agent job such that it doesn’t run in the middle of merge replication synchronization. Means when a merge replication is taking place, the job have to wait, or just run again until merge replication is done.

What would be the best way to do this?

Thank you.

Changing column Data Type when using merge replication: RFC on my SMO code.


I maintain an application for that uses SQL 2005 / 2008 for data persistence.
Some clients use Merge Replication (pull or push) to replicate data.

Some of the data the application stores should be "versioned". All versions of a row containing medical information should be stored, somewhere in a database. This means all updates and deletes to those rows should result in in 2 affected rows:

  • a copy of the row before the change
  • a row containing the change (or the deletion of the row in question)

I plan to achieve this using triggers on all the tables for wich "versioning" is required.
The old versions of a row may be stored in the same database, an other database (or a database on a linked server).

Unfortunalty, the AFTER UPDATE, DELETE triggers do not support TEXT, NTEXt an IMAGE data type columns.
Thus I am required to convert all text, ntext and image columns to their respective "new" data types, varchar(max), nvarchar(max) and varbinary(max).

This is not a big issue when the database is not published, but when it is... most articles (and posts) i've read suggest:

  1. Add a column of the target data type to the table, copy data from source column. rename columns and drop the source column.

  2. Create a temp table (with the s

Programmatically Changing the Profile Provider at Runtime


Dear All

I'm using one application but have multiple providers in my web.config for memberships, roles and profiles to allow my application to be used by different groups of users who need to connect to different databases.

This means I'm having to change the membership, role and profile providers on-the-fly in my code-behind files. So far I've taken care of the membership and roles a bit like this:

Dim RolePV As RoleProvider = Roles.Providers(GetSettingFromFile("Provider"))

However, I'm having trouble finding out how to do the same sort of thing for Profiles. I've looked at ProfileProvider and ProfileManager but I can't work it out how to access my the profile property that I've created in my web.config file called "ScreenSize". Normally you would just write Profile.ScreenSize to read or write to the property.

Please can you help me to understand how I access the profile property called ScreenSize by dynamically setting the profile provider first?

I'd be very grateful for any help or advice.

Many thanks



merge replication system tables fragmentation issue

I have Merge replication going on in my environment. The problem is that system tables like MSmerge_content, MS merge _tombstone and MSmerge_genhistory are getting fragmented. We are rebuilding indexes time to time daily. But we want some good fix. Just send some good idea guys?

Steps by Step document for configuration Merge Replication in 2005

Hi , Can anyone provide link to configure Merge Replication in 2005 with print screen.Also let me know the difference between Transcation level and Merge Replication. regards Vijay  

SQL Server 2005 Merge Replication

We did the following: We setup a database with all of standard tables, views, etc. We then put in place merge replication for a few of the tables within this database, including a tables called "Areas". We can execute SQL statements to insert rows into this table fine. We then applied an update script for this database to change a few tables by adding fields and changing indexes, etc.  We didn't change the "Areas" table though. After the update to the database structure, we get an error when trying to insert into this "Areas" table. The error message was the following: The insert failed. It conflicted with an identity range check constraint in database 'AETest', replicated table 'dbo.Areas', column 'AREPrimaryId'. If the identity column is automatically managed by replication, update the range as follows: for the Publisher, execute sp_adjustpublisheridentityrange; for the Subscriber, run the Distribution Agent or the Merge Agent.  The statement has been terminated.   What would cause such a problem and how do we resolve it?  The structure of the "Areas" table before and after the update is the following: USE   [AETest] GO /****** Object: Table [dbo].[Areas] Script Date: 08/24/2010 17:42:36 ******/ SET   ANSI_NULLS ON GO SET   QUOTED_IDENTIFIER ON GO SET   ANSI_PADDING ON

Merge Replication: How to give read access on snapshot share to a sql account

Hello All, I want to give read access to an sql account(not windows account). Can it be given or not. Someone please tell. Thanks saandii777

fragmentation in merge replication

I have Merge replication going on in my environment. The problem is that system tables like MSmerge_content, MS merge _tombstone and MSmerge_genhistory are getting fragmented. We are rebuilding indexes time to time daily. But we want some good fix. Just send some good idea guys?

configuring merge replication

Hi ALL,              I am configuring merge replication... For example Publisher A sql server 2008 ( databse adventureworks) subscriber B sql server 2000 ( database adventureworks) I already have database created at subscriber....both databases at publisher and subscriber are identical in structure but changes in data( at subscriber there some inserts and updates) now before i create new snapshot and applied to subscriber i want to upload changes which are at subscriber... how can i apply changes to publisher database before i run merge agent... TIA

Another merge agent for the subscription or subscriptions is running, or the server is working on a

Hi All, Using Merge Replication over the web (https). Server is running SQL Server 2008, client using SQL Server Express 2008. I am getting these error messages while trying to synchronize, and it won't let me sync: {call sp_MSensure_single_instance (N'{459D0BBA-53EC-4F65-AF52-E7DA478841DA}', 4)} Another merge agent for the subscription or subscriptions is running, or the server is working on a previous request by the same agent. Can you please advice what can be done to fix. Do I need to kill a process in SQL Server?

Merge Replication, Push Subscription : The snapshot takes centuries to apply

Well, not centuries, except that the users are storming the gate. I'm trying to find how to get the snapshot moved to the subscriber and applied in a reasonable time. Last time was successful, but took 2 1/2 days to build the subscriber database from the snapshot. Hillary responded: Something is very wrong here. You should be able to generate your snapshot, copy it manually over to the subscriber - using the altsnapshotfolder parameter and then apply it there. So now I have my snapshot, a folder with lots of .cft .bcp .dri .prc .sch  and .trg files. Getting this to the subscriber computer shouldn't take long. Once I get it there, how do I use it to get the subscriber set up?  You can't be successful at this unless you're at least 1/2 a bubble off level.

error in merge replication

Hi ALL,      I have merge replication configured between republishers( sql 2008) and subscribers( sql 2000)...i am getting the following error while trying to sync   The merge process could not update the list of subscriptions. (Source: MSSQL_REPL, Error number: MSSQL_REPL-2147201010) Get help: http://help/MSSQL_REPL-2147201010 Cannot insert duplicate key row in object 'dbo.sysmergesubscriptions' with unique index 'uc1sysmergesubscriptions'. (Source: MSSQLServer, Error number: 2601) Get help: http://help/2601 The subscription could not be created. (Source: MSSQLServer, Error number: 14057)   Any suggestions y i am getting this error TIA

2 way (bidirectional) MERGE replication?

Is this possible? I have SQL Server 3.5 CE on a windows mobile device which is going to do the majority of collection of information. I have SQL Server 2008 (needs to work with 2005 too) on a server and have no problem getting data from the server to the mobile device via replication but I need to know if it's possible and if so how, to get the merge to work the other way at the same time... or even via another means if it must do. Thanks for any help. Steve   It might also be helpful to add here that the server is configured for web synchronisation.

Cannot run Merge Replication via a schedulded Job.

Hi, I successfully implement a Merge Replication with Web Synchronization (SSL), my two servers are Windows Server 2008 R2 x64 with SQL Server 2008 R2. I configure the subscriber with RMO (http://msdn.microsoft.com/en-us/library/ms345207.aspx), and when I run the sql Job with the merge agent logged in, it works, however when the job is scheduled and the merge agent is not logged in, the sql job failed, with proxy server... I configure IE for the Merge agent not to use proxy, but it's like the job is not loading the user profile but use instead a default one. From what I read, it comes down to that. The sql job run under a proxy account (the merge agent). Further Steps: When I run the sql job under the sql server agent credentials, it works. Thx for any help. Sami Marzouki

Merge Replication and "Field size too large" problem

Hi,I have a single table database for tests configured on my server, I create another database using the same script that I use on my server on another server. I made a several inserts on the first database and I configure a merge replication between the two server and on the table article configure 2 integer columns to not be replicated and configure @pre_creation_cmd to none, because if I use another configuration on @pre_creation_cmd , when the snapshot applied it must recreated my table without the columns and I need then on another server. When I set @pre_creation_cmd  to none I need to create a rowguid column on the another server. My server is the Publisher and my another server is the publisher. I create the snapshot and when I sinconize the databases, the sinconization return that error:=================================================================================================The process could not bulk copy into table '"dbo"."CONSTS"'. (Source: MSSQL_REPL, Error number: MSSQL_REPL20037)Get help: http://help/MSSQL_REPL20037 Field size too large (Source: MSSQLServer, Error number: 0)Get help: http://help/0 To obtain an error file with details on the errors encountered when initializing the subscribing table, execute the bcp command that appears below.  Consult the BOL for more information on the bcp utility and its supported options. (Source:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend