Xml data stored using the SQL Server 2005 xml data type can be exported a number of ways and you can obviously write a managed stored procedure to do it.
However for a quick, one off, type approach you can use the BCP command.
bcp "SELECT [xml column name] FROM [TableName] FOR XML RAW" queryout c:\myOutputData.xml -SServerName -T -w -r -t
The downside of this is that, given the command above you’ll get your xml row data exported as shown;
{row 1 xml} {row 2 xml}
so you might need to do some mangling on the output file, or you can obviously change the initial SELECT statement to shape your output appropriately.
Published by