How to see the values of a table variable at debug

2019-01-08 03:53发布

Can we see the values (rows and cells) in a table valued variable in SQL Server Management Studio (SSMS) during debug time? If yes, how?

enter image description here

9条回答
Juvenile、少年°
2楼-- · 2019-01-08 04:23

Why not just select the Table and view the variable that way?

SELECT * FROM @d
查看更多
The star\"
3楼-- · 2019-01-08 04:29

Sorry guys, I'm a little late to the party but for anyone that stumbles across this question at a later date, I've found the easiest way to do this in a stored procedure is to:

  1. Create a new query with any procedure parameters declared and initialised at the top.
  2. Paste in the body of your procedure.
  3. Add a good old fashioned select query immediately after your table variable is initialised with data.
  4. If 3. is not the last statement in the procedure, set a breakpoint on the same line, start debugging and continue straight to your breakpoint.
  5. Profit!!

messi19's answer should be the accepted one IMHO, since it is simpler than mine and does the job most of the time, but if you're like me and have a table variable inside a loop that you want to inspect, this does the job nicely without too much effort or external SSMS plugins.

查看更多
ら.Afraid
4楼-- · 2019-01-08 04:33

That's not yet implemented according this Microsoft Connect link: Microsoft Connect

查看更多
登录 后发表回答