Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
fralo
Posting Yak Master
161 Posts |
Posted - 2011-10-11 : 12:27:00
|
| Hi,How can I export sql results to an xml file? I have the following in place. The code generates an xml file successfully within management studio, but I would like for it to write a file to my C drive. Is there a simple addition I could make to my code for this to work? create proc jailinfo as declare @xmlquery xml set @xmlquery = (select top 10 * from jailbook for xml auto, root('AddBookingRecord'), ELEMENTS) select @xmlquery go Thanks for your help. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
fralo
Posting Yak Master
161 Posts |
Posted - 2011-10-11 : 12:43:59
|
| Well I already had this in place. Plus, the bcp command comes with so many parameters (e.g. -c, -t) that I became frustrated. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-11 : 13:06:43
|
| you just need to use query out option using the above query and provide output file path.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
fralo
Posting Yak Master
161 Posts |
Posted - 2011-10-11 : 13:24:22
|
| Like this?bcp "SELECT * FROM jailbook" queryout c:\sample.xmlIt gives 'Incorrect syntax near 'queryout'.Appreciate your help and patience. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|