且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在MS SQL Management Studio 2012中调试会话期间如何查看表变量中的数据?

更新时间:2023-02-06 18:01:57

虽然我找不到任何文字,任何在那里,明确声明您不能检查表变量,我不认为这是可能的。从 Transact-SQL Debugger

Whilst I can't find any documetation, anywhere, that explicitly states that you cannot inspect table variables, I don't believe that it's possible. From Transact-SQL Debugger


本地观看。这些窗口显示当前分配的Transact-SQL表达式。表达式是Transact-SQL子句,用于计算单个标量表达式。 Transact-SQL调试器支持查看引用Transact-SQL变量,参数或以@@开头的内置函数的表达式。这些窗口还显示当前分配给表达式的数据值。

Locals and Watch. These windows display currently allocated Transact-SQL expressions. Expressions are Transact-SQL clauses that evaluate to a single, scalar expression. The Transact-SQL debugger supports viewing expressions that reference Transact-SQL variables, parameters, or the built-in functions that have names that start with @@. These windows also display the data values that are currently assigned to the expressions.

我的重点

就是你只能检查标量。

关于你尝试使用立即窗口, a href =http://msdn.microsoft.com/en-GB/library/ms165035(v=vs.100).aspx =noreferrer>调试器命令和功能的限制说: / p>

As to your attempt to use the Immediate window, the Limitations on Debugger Command and Features says:


显示立即窗口,但您无法对其进行任何有用的操作,例如将变量设置为值或查询数据库。

The Immediate window is displayed, but you cannot do anything useful with it, such as setting a variable to a value, or querying the database.






我从来没有真正使用过调试器 - 每次我研究它,我遇到这样的限制。


I've never really used the debugger much - everytime I've looked into it, I encounter limitations like this.

这就是为什么我仍然倾向于使用旧Skool/printf方法来调试SQL - 在整个代码中包含额外的 SELECT * ,显示当前表的状态,以及额外的 PRINT RAISERROR 显示其他状态的消息等等,然后正常运行代码,直到你已经它成型。

That's why I still tend to use "old-skool"/"printf" approaches to debug SQL - include extra SELECT *s liberally throughout the code showing the current state of tables, and extra PRINT or RAISERROR messages that show other states, etc. And then just run the code normally, until you've bashed it into shape.