如何在构建时输入 .sql 文件但将其包含在架构比较中 [英] How to ingore a .sql file on build but include it on schema compare

查看:25
本文介绍了如何在构建时输入 .sql 文件但将其包含在架构比较中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 SQL Server 数据库项目 的构建中忽略一些 SQL 文件,但将它们包含在架构比较中?

Is there a way to ignore some SQL files in the build of a SQL Server Database Project but include them on the schema compare?

我的意思是,我们有一些导致构建失败的 SQL 文件(它们指向我们无权访问的链接服务器).我们想要的是从构建中排除它(因此构建通过)但将其包含在模式比较中(以便我们可以查看它是否被修改).

I mean, we have some SQL files that cause failures in the build (they point to a linked server which we have no access). What we want is to exclude it from the build (so the build passes) but include it on schema comparisons (so we can see if it was modified).

有什么建议吗?

推荐答案

我承认我没有提供您想要的解决方案,但您尝试做的是解决 SSDT.这可能会造成比其价值更多的痛苦,而且通常更容易正确解决问题 - 在这种情况下,脚本无法构建.

I acknowledge I'm not providing the solution you want, but what you're trying to do is work around SSDT. This can cause more pain than its worth and it's often easier to properly fix the problem - in this case, the script that doesn't build.

我假设链接服务器的问题是因为它有一个未解析的引用 - 在这种情况下,我建议改用 SQLCMD 变量.

I'm assuming the issue you have with the linked server is because it has an unresolved reference - in which case I'd recommend using a SQLCMD variable instead.

SQLCMD 变量将抽象出链接服务器名称,因此 SSDT 将停止尝试解析它,并且应该允许您构建.部署数据库时(使用发布配置文件或 sqlpackage.exe),您可以指定要使用的 SQLCMD 值,在进行比较时也是如此.

The SQLCMD variable will abstract out the linked server name, so SSDT will stop trying to parse it, and should allow you to build. When you deploy the database (using a Publish Profile or sqlpackage.exe) you can specify the SQLCMD value you want to use, and the same for when you do a compare.

以下是以这种方式使用 SQLCMD 变量的示例:http://ntsblog.homedev.com.au/index.php/2013/03/13/sqlcmd-variables-linked-server-connection-intellisense/

Here's an example of using a SQLCMD variable this way: http://ntsblog.homedev.com.au/index.php/2013/03/13/sqlcmd-variables-linked-server-connection-intellisense/

如果这对您不起作用,请告诉我您使用的对象类型/一些示例代码或屏幕截图,我会尽力帮助您.

If this doesn't work for you, let me know what sort of object your working with / some sample code or screenshots and I'll try and help you out.

这篇关于如何在构建时输入 .sql 文件但将其包含在架构比较中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆