SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL SnapShot Replication not copying Constraint Key


SQL SnapShot Replication not copying Constraint Key

Author
Message
tornado_moore_03
tornado_moore_03
Grasshopper
Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)

Group: General Forum Members
Points: 16 Visits: 15
We have a domain joined SQL 2008 R2 server performing a snapshot database replication to a non-domain joined SQL 2008 R2 server. The snapshot replication is working with one exception. Under one of the tables, there is a Key, Constraint and Index that are part of the database. The Key and Indexes is copying over. However,
the constraint is not. Anyone seen this issue and why would the Key and Index copy but not the Constraint?

Thx in advance for any assistance provided.
anthony.green
anthony.green
SSC Guru
SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)

Group: General Forum Members
Points: 86460 Visits: 8671
Check the article properties, generally its only primary keys and unique constraints that get copied over.

Someone may have changed the indexes setting, so just need to change the default constraint and other constraint settings to be included.



How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


Attachments
ArticleProperties.PNG (39 views, 59.00 KB)
tornado_moore_03
tornado_moore_03
Grasshopper
Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)

Group: General Forum Members
Points: 16 Visits: 15
Attached is screen shot of the settings. I tried to set the Copy Foreign Key Constraints to True but every time I save and close out, it goes back to False.

Thx in advance for any assistance provided.
Attachments
key constraint.PNG (63 views, 42.00 KB)
Michael L John
Michael L John
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16880 Visits: 9555
It's going to do that. I honestly do not know the real answer, but this is my take. I have seen this behavior before.

Replication is not "smart" enough to determine that Table A needs to be in place before Table B because of the parent-child constraint.
It generates the snapshot objects in no order, so it may actually try to add the child table before the parent table exists and is populated.

if this was transactional replication, I would strongly recommend removing the foreign keys as well as defaults and check constraints.

Since it's snapshot replication, simply create all of the keys in a post-snapshot script.

Michael L John
If you assassinate a DBA, would you pull a trigger?
To properly post on a forum:
http://www.sqlservercentral.com/articles/61537/
feersum_endjinn
feersum_endjinn
UDP Broadcaster
UDP Broadcaster (1.4K reputation)UDP Broadcaster (1.4K reputation)UDP Broadcaster (1.4K reputation)UDP Broadcaster (1.4K reputation)UDP Broadcaster (1.4K reputation)UDP Broadcaster (1.4K reputation)UDP Broadcaster (1.4K reputation)UDP Broadcaster (1.4K reputation)

Group: General Forum Members
Points: 1439 Visits: 448
We have had the same issue (SQL Server 2012, SP3) and we think it's because of this:

The NOT FOR REPLICATION option is specified by default for foreign key constraints and check constraints; the constraints are enforced for user operations but not agent operations.

Source: https://docs.microsoft.com/en-us/sql/relational-databases/replication/administration/frequently-asked-questions-for-replication-administrators

Also some further information about IDENTITY columns in a replication scenario:

https://docs.microsoft.com/en-us/sql/relational-databases/replication/publish/replicate-identity-columns
Michael L John
Michael L John
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16880 Visits: 9555
emailt@gmail.com - Wednesday, February 7, 2018 8:14 AM
We have had the same issue (SQL Server 2012, SP3) and we think it's because of this:

The NOT FOR REPLICATION option is specified by default for foreign key constraints and check constraints; the constraints are enforced for user operations but not agent operations.

Source: https://docs.microsoft.com/en-us/sql/relational-databases/replication/administration/frequently-asked-questions-for-replication-administrators

Also some further information about IDENTITY columns in a replication scenario:

https://docs.microsoft.com/en-us/sql/relational-databases/replication/publish/replicate-identity-columns

Note: Three year old thread.


Michael L John
If you assassinate a DBA, would you pull a trigger?
To properly post on a forum:
http://www.sqlservercentral.com/articles/61537/
feersum_endjinn
feersum_endjinn
UDP Broadcaster
UDP Broadcaster (1.4K reputation)UDP Broadcaster (1.4K reputation)UDP Broadcaster (1.4K reputation)UDP Broadcaster (1.4K reputation)UDP Broadcaster (1.4K reputation)UDP Broadcaster (1.4K reputation)UDP Broadcaster (1.4K reputation)UDP Broadcaster (1.4K reputation)

Group: General Forum Members
Points: 1439 Visits: 448
Yes I knew that when I posted a reply. However in the spirit of community driven content and the fact that I looked at this thread and found it relevant to the issue I was facing I thought I'd share further information that someone else might find useful. Maybe they might stumble across it in another three years or so.

But thank you for taking the time to let me know what I already knew. 👍🏾
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search