Printing table contents for debugging purposes in T-SQL
August 23, 2013
0 Comments
Sometimes you just want to add a print statement in a stored procedure to output the contents of a table.
Then you can use the "FOR XML" statement in T-SQL:
declare @Data_as_xml xml set @Data_as_xml = (select top 4 * from sys.tables FOR XML PATH('')) print convert(varchar(8000), @Data_as_xml)
Result:
Tags: T-SQL