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:

 

image

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.