How to see the values of a table variable at debug time in T-SQL? How to see the values of a table variable at debug time in T-SQL? sql sql

How to see the values of a table variable at debug time in T-SQL?


DECLARE @v XML = (SELECT * FROM <tablename> FOR XML AUTO)

Insert the above statement at the point where you want to view the table's contents. The table's contents will be rendered as XML in the locals window, or you can add @v to the watches window.

enter image description here


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


This project https://github.com/FilipDeVos/sp_select has a stored procedure sp_select which allows for selecting from a temp table.

Usage:

exec sp_select 'tempDb..#myTempTable'

While debugging a stored procedure you can open a new tab and run this command to see the contents of the temp table.