简体   繁体   English

包括但不能删除SQL架构比较

[英]Include but not Delete SQL Schema Compare

I am attempting to use SQL Schema Compare in Visual Studio 2013/15 and am running into the problem that discluding tables from delete removes them from being processed at all. 我试图在Visual Studio 2013/15中使用SQL模式比较,并且遇到了从删除表中删除表的问题,使它们完全无法处理。

The issue is that the tables it is trying to delete are customer made tables, so when we sync our version against their databases it asks to delete them. 问题是它试图删除的表是客户制造的表,所以当我们将我们的版本与他们的数据库同步时,它要求删除它们。 We do not want to delete them, but some of their tables have constraints on ours so when it attempts to CCDR it fails due to table constraints. 我们不想删除它们,但是它们的一些表对我们的表有约束,因此当它尝试CCDR时由于表约束而失败。 Is there a way to add the table to be (re-created? like the rest of them?), without writing scripts for each client to do what SQL Schema Compare already does just for those few tables? 有没有办法添加表(重新创建?像其他人一样?),而不是为每个客户端编写脚本来执行SQL Schema Compare已经为这几个表做的事情?

Red-Gate's SQL Compare does this somehow, but it's hidden from us so not quite sure how it's achieved. Red-Gate的SQL Compare以某种方式做到这一点,但它对我们隐藏,所以不太确定它是如何实现的。 Discluding doesn't delete, but does not error on the script either. 删除不删除,但脚本上也没有错误。

UPDATE: 更新:

The option "Drop constraints not in source" does not appear to work correctly. “删除不在源中的约束”选项似乎无法正常工作。 It does drop some, however there are others that it just does not drop the constraints. 它确实会丢掉一些,但是还有一些它不会放弃约束。 In red-gate's tool, when we compared I found how to get the SQL from it, and their product doesn't say the table needs to be updated at all, while Visual Studio's does. 在red-gate的工具中,当我们比较时,我发现了如何从中获取SQL,而他们的产品并没有说表需要根据需要进行更新,而Visual Studio则可以。 They seem to work almost identical, but the tables that fail are the ones that shouldn't be update at all (read below) 它们似乎工作几乎相同,但失败的表是根本不应更新的表(见下文)

Update 2: 更新2:

Another problem I've found is "Ignore column collation" also doesn't work correctly, as tables that shouldn't be getting dropped are being told they need to be updated even though it's only order of column changes, not actual column or data changes, which makes this feel like more of a bug report than anything. 我发现的另一个问题是“Ignore column collat​​ion”也无法正常工作,因为不应该被删除的表被告知他们需要更新,即使它只是列更改的顺序,而不是实际的列或数据变化,这使得这更像是一个错误报告而不是任何东西。

忽略列校对

仍然显示列整理

My suggestion with these types of advance data calculations is to not use Visual Studio. 我对这些类型的高级数据计算的建议是不使用Visual Studio。 Put the logic on the Sql engine and write the code for this in Sql. 将逻辑放在Sql引擎上,并在Sql中为此编写代码。 Due to the multi user locking issues of a Sql engine these types of processes are prone to fail when the wrong combinations of user actions happen at the same time. 由于Sql引擎的多用户锁定问题,当用户操作的错误组合同时发生时,这些类型的进程很容易失败。 The Visual Studio tool can not interface with the data locking issues due to records changing that the Sql engine can. 由于Sql引擎可以更改记录,Visual Studio工具无法与数据锁定问题进行交互。 If you even get this to work it will only be safe to run if you are in single user mode. 如果您使用它,只有在单用户模式下才能安全运行。

It is a nice to use tool, easier than writing Sql but there are huge reliability and consistency risks for going down this path. 这是一个很好的使用工具,比编写Sql更容易,但是沿着这条路走下去存在巨大的可靠性和一致性风险。

I don't know if this will help but I've found this paragraph on the following page: https://msdn.microsoft.com/en-us/library/hh272690(v=vs.103).aspx 我不知道这是否会有所帮助,但我在下面的页面中找到了这一段: https//msdn.microsoft.com/en-us/library/hh272690(v = vs.103).aspx

The update will fail because our change involves changing a column from NOT NULL to NULL and as a result causes data loss. 更新将失败,因为我们的更改涉及将列从NOT NULL更改为NULL,从而导致数据丢失。 If you want to proceed with the update, click on the Options button (the fifth one from the left) on the toolbar for the Schema Compare and uncheck the block incremental deployment if data loss option. 如果要继续更新,请单击工具栏上的“选项”按钮(左起第五个)以进行架构比较,如果数据丢失选项,则取消选中块增量部署。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM