开发者

SSMS intermittently executes my highlighted script against the wrong database

On SQL Server 2008 R开发者_开发知识库2, 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?


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.


I also prefer to fully qualify my tables (database.schema.table) in all queries rather than rely on a use statement.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜