在SQL 2008 Management Studio中调试时,在存储过程中查询临时表 [英] Query temp table in stored proc whilst debugging in SQL 2008 Management Studio

查看:513
本文介绍了在SQL 2008 Management Studio中调试时,在存储过程中查询临时表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常大的存储过程,调用其他存储过程并将结果应用到临时表中。



我在SQL 2008 Management Studio中进行调试,可以使用观察窗口查询本地参数,但是如何在调试时查询临时表?



如果不可能有另外一种方法?我已经阅读了关于使用表变量,可以查询这些吗?如果是,我该怎么做?

解决方案

使用全局临时表,即使用双哈希。

  insert into ## temp select ... 

调试时可以暂停SP,而在另一查询窗口中可以查询##表。

  select * from ## temp 

单个哈希表(#tmp)是会话具体且仅在会话中可见。


I have a really large stored procedure which calls other stored procedures and applies the results into temp tables.

I am debugging in SQL 2008 Management Studio and can use the watch window to query local parameters but how can I query a temp table on whilst debugging?

If its not possible is there an alternative approach? I have read about using table variables instead, would it be possible to query these? If so how would I do this?

解决方案

Use global temporary tables, i.e. with double hash.

insert into ##temp select ...

While debugging, you can pause the SP at some point, and in another query window, the ## table is available for querying.

select * from ##temp

Single hash tables (#tmp) is session specific and is only visible from the session.

这篇关于在SQL 2008 Management Studio中调试时,在存储过程中查询临时表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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