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

前端 未结 10 1932
悲哀的现实
悲哀的现实 2020-11-29 15:30

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?

相关标签:
10条回答
  • 2020-11-29 16:29

    I have come to the conclusion that this is not possible without any plugins.

    0 讨论(0)
  • 2020-11-29 16:31

    In the Stored Procedure create a global temporary table ##temptable and write an insert query within your stored procedure which inserts the data in your table into this temporary table.

    Once this is done you can check the content of the temporary table by opening a new query window. Just use "select * from ##temptable"

    0 讨论(0)
  • 2020-11-29 16:32

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

    SELECT * FROM @d
    
    0 讨论(0)
  • 2020-11-29 16:33

    If you are using SQL Server 2016 or newer, you can also select it as JSON result and display it in JSON Visualizer, it's much easier to read it than in XML and allows you to filter results.

    DECLARE @v nvarchar(max) = (SELECT * FROM Suppliers FOR JSON AUTO)
    

    0 讨论(0)
提交回复
热议问题