是否可以在脚本中自动强制使用 SQLCMD 模式?
我们使用的是 Visual Studio Database Professional,它大量使用 SQLCMD 变量来区分部署时的环境。
我知道有几个指令可用于设置上下文(例如:connect 用于服务器名称)。脚本本身是否有办法强制执行 SQLCMD 模式?我们部署过程的一部分是让 DBA 检查并执行脚本,这将是一个很好的安全网(因此我不必提醒他们将执行模式设置为 SQLCMD)。
We're using Visual Studio Database Professional and it makes heavy use of SQLCMD variables to differentiate between environments while deploying.
I know there's several directives available for setting context (like :connect for server name). Is there a way within the script itself to force SQLCMD mode for execution? Part of our deployment process is to have DBA's examine and execute the scripts and it would be a nice safety net (so I don't have to remind them to set their execution mode to SQLCMD).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不是一个解决方案,但作为一种解决方法,您可以将脚本嵌入到一些警告中。 这篇文章启发了我编写这段代码:
Not a solution, but as a work-around, you could embed your script in some warning. This post inspired me to this code:
这似乎不可能。我什至检查了 SSMS 项目模式。
但是,如果您在 BIDS 中创建数据库项目,则预部署和部署过程将在 BIDS 中进行。默认情况下,部署后脚本在 SQLCMD 模式下运行。
我知道这不是您想要的答案,但这是我能给您的最好的答案,无需创建一个自定义 SSMS 插件,该插件将根据脚本文件中的某些文本为您完成此操作。
This does not seem to be possible. I even checked the SSMS project mode.
However, if you create a database project in BIDS, the pre-deploy & post-deploy scripts run in SQLCMD mode by default.
I know that is not the answer you want, but it is the best I can give you w/o resorting creating a custom SSMS plugin that would do it for you based on some text in the script file.