any way to see table variable data in the ssms debugger?

  • Hi, is there a way to see the data of a table variable in the SSMS debugger? For example, if I set a breakpoint in SSMS and look at a populated table variable named @MyTable in the Locals tab at the bottom of the IDE, a value of "(table)" is displayed. There does not appear to be a way to expand or drill into this variable in the debugger to see the data. Do you know if there's a way to do this through the debugger or do you use an alternate approach when using the SSMS debugger?

  • This is a very common question, and no, there is no direct way to do this.

    From https://msdn.microsoft.com/en-us/library/cc646012.aspx, the documentation on the debugger:

    Expressions are Transact-SQL clauses that evaluate to a single, scalar value, such as variables or parameters. The left debugger window can display the data values that are currently assigned to expressions in up to five tabs or windows: Locals, Watch1, Watch2, Watch3, and Watch4.

    (emphasis mine)

    There is a clunky workaround, by declaring a variable using the XML datatype, and setting its value to the result of a SELECT from the table variable. You can then see the value of the XML variable.

    It isn't so pretty, but it's the only workaround I know.

    Cheers!

    EDIT: I should say it's the only workaround if you absolutely must use the debugger. It's probably better not to do it using the debugger, and just select from the table variable into a permanent table at the points you're interested in, and just track it that way.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply