Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am using merge replication in SQL 2012.

Why can't you mark default constraints as NOT FOR REPLICATION? You can disable all default constraints for a merge article, but it is all or nothing so it doesn't seem to offer enough control.

How about this scenario,

  1. The user inserts a record 'Shape' at a client
  2. The 'Shape' has a default constraint to set the NumberOfSides field to 4
  3. The client user edits the value of NumberOfSides and sets it to 5
  4. They sync with the server

When they sync with the server won't it repeat the default constraint and set the value of 'NumberOfSides' back to 4?

Am I missing something here?

I don't want to disable the default constraints being replicated to the client either because there are valid default values that need to be set. The client side user needs to have these values set to use the software.

UPDATE:

The explanation about the default constraint being applied only once makes sense.

So my only remaining question is if I have default contraints which use sequences I am in trouble because sequences cannot be replicated. Are these my only two options?

  1. Turn off all default constraints for a particular table (not ideal if some of them are not for sequences)
  2. Create the sequences manually at the client side, and then create a custom handler to apply the correct sequence values at the server when syncing
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

When data is replicated from one server to another using SQL Replication all the values which were inserted into the row are sent along. Default constraints only apply when no value has been specified for the column. If the user specifies a value of 5 then 5 will be replicated and inserted into the table.

share|improve this answer
    
Makes sense. I have updated the question. –  peter Aug 21 '12 at 23:56
    
In this case I would probably just create the sequences manually on the remote side. That or stick with replicatable objects like the identity property. –  mrdenny Aug 22 '12 at 23:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.