Hi,
I need to create an xml file. First I write some initial xml to the file:
--Create an xml file named cmts_xml.xml
exec master..xp_cmdshell 'echo ^<?xml version="1.0" ?^> > f\projects\cmts_xml\cmts_xml.xml'
exec master..xp_cmdshell 'echo ^<request^> >> f\projects\cmts_xml\cmts_xml.xml'
exec master..xp_cmdshell 'echo ^<query app_key="AUDIT_TEST"^> >> F\Projects\cmts_xml\cmts_xml.xml'
exec master..xp_cmdshell 'echo ^<device-list^> >> F\Projects\cmts_xml\cmts_xml.xml'
Then here's where I get in trouble. This next command works great, BUT it overwrites my previous entries in the file.
exec master..xp_cmdshell 'bcp "cdvsupport.dbo.VW_CMTS_XML" out F\Projects\cmts_xml\cmts_xml.xml -c -SMachelmc01 -Uuser -Ppassword'
exec master..xp_cmdshell 'echo ^</device-list^> >> F\Projects\cmts_xml\cmts_xml.xml'
exec master..xp_cmdshell 'echo ^</query^> >> F\Projects\cmts_xml\cmts_xml.xml'
exec master..xp_cmdshell 'echo ^</request^> >> f\projects\cmts_xml\cmts_xml.xml'
How can I rewrite this so when the result set is written to the file, it doesn't overwrite what's already there ?
Thanks for any help,
Paul
I need to create an xml file. First I write some initial xml to the file:
--Create an xml file named cmts_xml.xml
exec master..xp_cmdshell 'echo ^<?xml version="1.0" ?^> > f\projects\cmts_xml\cmts_xml.xml'
exec master..xp_cmdshell 'echo ^<request^> >> f\projects\cmts_xml\cmts_xml.xml'
exec master..xp_cmdshell 'echo ^<query app_key="AUDIT_TEST"^> >> F\Projects\cmts_xml\cmts_xml.xml'
exec master..xp_cmdshell 'echo ^<device-list^> >> F\Projects\cmts_xml\cmts_xml.xml'
Then here's where I get in trouble. This next command works great, BUT it overwrites my previous entries in the file.
exec master..xp_cmdshell 'bcp "cdvsupport.dbo.VW_CMTS_XML" out F\Projects\cmts_xml\cmts_xml.xml -c -SMachelmc01 -Uuser -Ppassword'
exec master..xp_cmdshell 'echo ^</device-list^> >> F\Projects\cmts_xml\cmts_xml.xml'
exec master..xp_cmdshell 'echo ^</query^> >> F\Projects\cmts_xml\cmts_xml.xml'
exec master..xp_cmdshell 'echo ^</request^> >> f\projects\cmts_xml\cmts_xml.xml'
How can I rewrite this so when the result set is written to the file, it doesn't overwrite what's already there ?
Thanks for any help,
Paul