SSMS 间歇性地针对错误的数据库执行我突出显示的脚本
在 SQL Server 2008 R2 上,我有一个显式开头的脚本
USE MyDatabase;
,并且它永远不会切换到任何其他数据库; 当我执行整个脚本时,它会针对正确的数据库运行,正如我在第一行中指定的那样。
但是,如果在运行整个脚本后,突出显示并运行其中的一部分,SSMS 会间歇性地针对另一个数据库运行它。
这可能非常危险,而我使用以前版本的 SQL Server 时从未发生过这种情况! 我怎样才能避免这个危险的错误?
On SQL Server 2008 R2, I have a script that explicitly begins with
USE MyDatabase;
and it never ever switches to any other database;
When I execute the whole script, it runs against the correct database, as I have specified in the first line.
If, however, after I have ran the whole script, I highlight and run a part of it, SSMS intermittently runs it against another database.
This is potentially very dangerous, and it never happened to me with previous versions of SQL Server!
How can I avoid this dangerous bug?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这听起来像这个 Connect bug< /a> 如果您有 RAISERROR 或者您的 SSMS 会话因其他原因断开连接(这可能是由于不稳定的网络,您可能没有注意到它的发生),就会发生这种情况。这是一个危险的错误,虽然连接项没有明确说明,但我建议您应用 SQL Server 2008 R2 SP1 到您的工作站,据我所知,它已修复。
This sounds like this Connect bug that occurs if you have a RAISERROR or your SSMS session gets otherwise disconnected (this can be due to flaky network and you may not notice that it happened). It is a dangerous bug and while the Connect item doesn't state so explicitly, I suggest you apply SQL Server 2008 R2 SP1 to your workstation, as I've heard that it is fixed there.
我还喜欢在所有查询中完全限定我的表 (database.schema.table),而不是依赖于 use 语句。
I also prefer to fully qualify my tables (database.schema.table) in all queries rather than rely on a use statement.