I basically have a database and an application, and what i want to do is creating a second database and a second application that is running mostly independent. Setting this up is easy, but what I want now is a connection between both, so that the configuration tool is abled to configure both setups at the same time. For an simple example we could assume that the whole configuration is done in only one table in the database. So i basically see two ways to do that:
Modify the configuration tool, so that it will write to both instead of only one server, or use replication to get the configuration table from one db to the other.
As I would have to go deep in alot of old code that I did not write myself, I would prefer it by far to get this done by replication.
As SQL Server 2008R2 is used, I have snapshot, transactional and merge replication available. Snapshot is kind of bad because I want the whole thing to be “realtime” and that is not how snapshots work.
Transactional and merge sound both pretty nice, and I think both would be possible, but I experienced some Problems with that. Transactional replication kills the constraints on the subscriber, which is not acceptable. Merge replication does not do that, but when I have the second database running I cannot apply the merge replication because it wants to delete the table which it cannot because of the existing constraints.
I tried to set up both of those replications without initialisation, but that did not work at all. I guess I have to set up something different for that but i dont know what.
Is there a way to get this running like I want it to, or is there even another possible way that I missed completely?
We use transactional replication on a large scale to do more or less exactly what you’re describing here, distributing configuration from a central point to many subscriber databases.
Whilst you may not be happy with the default options offered by transactional replication, you have a lot of control over how it behaves.
The schema options bitmask, set when adding an article to a publication, allows you control over pretty much all aspects of the DDL replicated to the subscriber – for full details, see the documentation on
sp_addarticle. The replication GUI gives you access to most of these settings, but you may need to use T-SQL scripts to get exactly what you want. I don’t have access to a database at the moment to check whether check, default and foreign-key constraints are all surfaced in the GUI.Even the default transactional replication would be appropriate in this scenario if it’s really acceptable that the replication is one-way, since there’s no need to maintain the constraints on the read-only database, since no data is being inserted.