25

I have recently taken over a project, and I have discovered that in most tables the primary key has the property "NOT FOR REPLICATION".

I'm no DBA, but surely in most databases, a record without a primary key would be considered corrupted. The primary key of most of these records would almost certainly be used as a foreign key somewhere.

Was this an error on the part of the previous developer (who no longer works for the company), or is there some other logic involved? We don't even use replication in the production environment, so this doesn't actually affect anything serious anyway but I was wondering if there are any other side-effects of removing all these directives that I'm not aware of.

I haven't found many useful hits for a number of search terms related to this topic, so I'm fairly certain that this is just a silly error that I need to reverse, so this question is really to assuage my paranoia.

31

NOT FOR REPLICATION indicates that when a record is replicated to this table, any value that is inserted into the identity column via the replication agent keeps it's original value from the source system, but any records added locally still increment the identity value.

UPDATE: Old Link broken

Here is the link to the table_constraint docs that details what setting NOT FOR REPLICATION will do:

Table Constraint

2
  • 2
    Link has rotten – Aleksandr Kravets Oct 29 '19 at 15:43
  • @AleksandrKravets cheers, updated – steoleary Dec 12 '19 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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