如何知道哪些临时表当前在 SQL Server 范围内?
我经常收到错误:
Msg 208, Level 16, State 0, Line 1
Invalid object name '#foo'.
Msg 3701, Level 11, State 5, Line 1
Cannot drop the table '#foo', because it does not exist in the system catalog.
我如何知道范围内有哪些临时表? 它们显然不会像基表那样出现在 SSMS 中。
I often get the errors:
Msg 208, Level 16, State 0, Line 1
Invalid object name '#foo'.
Msg 3701, Level 11, State 5, Line 1
Cannot drop the table '#foo', because it does not exist in the system catalog.
How do I know what temporary tables there are in scope? They obviosly don't show up in SSMS like base tables do.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在尝试对表执行查询之前,您可以检查该表是否存在。
You can check to see if the table exists before trying to perform a query on it.
扩展 Brandon 的答案...
在 SSMS 查询窗口 1 中:
在窗口 2 中:
##bar
在两个会话中都可见,正如预期的那样。#foo
仅在本地会话中。Expanding Brandon's answer...
In SSMS query window 1:
In window 2:
##bar
is visible in both sessions, as expected.#foo
in the local session only.