I would like to export a table from SQL Server 2012 to an XML file. I found a good answer , and here how to make XML the result of the SQL Server database query, but still I do not have how to physically save the output to a file.
SQL query:
SELECT [Created], [Text]
FROM [db304].[dbo].[SearchHistory]
FOR XML PATH('Record'), ROOT('SearchHistory')
I am using Microsoft SQL Server Management Studio to accomplish this result. I see XML in the result window, but I cannot save it.
The context menu has “Save the result as ..”, but with 98900 lines, I exit my 8 GB memory with this option.
Is there a way to save this request directly in an XML file on disk?