Job to write data from a query to an XML file

1

I need to write the result of a query in an XML through a job that will run daily scheduled in SQL Server. The procedure already returns the result in XML format with tags, in a variable. I just need to play the contents of this variable in XML. What is the best way to generate this XML? How do I define the path that the XML will be written to and how do I define the file name?

Thanks!

    
asked by anonymous 07.04.2016 / 15:06

1 answer

0

Well, basically using the command xp_cmdshell . :

DECLARE @command VARCHAR(8000) = 'echo ' + @xml + ' > c:\meus\diretorios\teste.txt';

EXEC xp_cmdshell @command;
    
07.04.2016 / 19:55