Je kunt queryresultaten als XML naar een bestand schrijven met bcp.exe en xp_cmdshell.
Schakel eerst advanced options en xp_cmdshell in:
EXEC master.dbo.sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC master.dbo.sp_configure 'xp_cmdshell', 1;
RECONFIGURE;Daarna kun je exporteren:
EXEC xp_cmdshell 'bcp "SELECT [Created], [Text] FROM [db304].[dbo].[SearchHistory] FOR XML PATH(''Record''), ROOT(''SearchHistory'')" queryout "C:\bcptest.xml" -T -c -t,';Let op de dubbele enkele quotes binnen de XML-directives. Zet xp_cmdshell daarna weer uit als je het niet meer nodig hebt.