NOT FOR REPLICATION
NOT FOR REPLICATION is a SQL statement in the Constraints category. SQL Server: marks constraint as not enforced during replication. Allows replication to bypass FK checks. The syntax is CONSTRAINT name FOREIGN KEY (col) REFERENCES parent(id) NOT FOR REPLICATION;. It returns replication-safe constraint. A typical example: CREATE TABLE orders ( id INT PRIMARY KEY, customer_id INT, CONSTRAINT fk_customer FOREIGN KEY (customer_id) REFERENCES customers(id) NOT FOR REPLICATION ); -- During normal operations, FK is enforced -- During replication, the FK is NOT checked -- Prevents replication errors when data arrives out of order -- Also available for: UNIQUE, CHECK, FOREIGN KEY constraints -- NOT available for: PRIMARY KEY, DEFAULT A close relative is PRIMARY KEY, which a column or set of columns that uniquely identifies each row. Only one PK per table. Automatically creates a unique index. A close relative is FOREIGN KEY, which ensures referential integrity: values in this column must exist in the referenced parent table.