Link to home
Start Free TrialLog in
Avatar of hennessym

asked on

How do I exclude the tablename/owner from an XML file generated by SQL Server 2005?

I'm using bcp to generate an XML file that I'll e-mail to a customer via sp_send_dbmail.  The command I'm using looks something like this:

xp_cmdshell 'bcp "SELECT field1, field2, field3 FROM mydb.dbo.mytable FOR XML auto, elements, root(''root'')" queryout c:\test.dat -T -c'

This works well with the exception that each record begins with a tag indicating the table name/owner, e.g.: <mydb.dbo.mytable>.  

Is there anyway to prevent this from happening?  I'd like to exclude that from the file I send the customer if at all possible.  The only solution I can think of would be to insert the xml into a temp table and then strip the tag via an update query.

Thanks - Matt
Avatar of chapmandew
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hennessym


Awesome, thanks!