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 |
|
derach2000
Starting Member
37 Posts |
Posted - 2010-04-27 : 04:37:14
|
| Hi, I was wondering is there a way to directly save the result of an query to a XML file on the disk. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-27 : 04:41:09
|
| Yup.use FOR XML clause and use bcp to store it in file------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
sathiesh2005
Yak Posting Veteran
85 Posts |
Posted - 2010-04-27 : 05:50:05
|
| Hi,Code here.DECLARE @ExecCmd VARCHAR(3000) SET @ExecCmd='bcp "SELECT COL1,COL2,COL3,...COLn FROM table FOR XML AUTO,ELEMENTS" queryout d:\FileName.xml -w -r "" -S 102.87.10.10 -U user -P pwd' EXEC master..xp_cmdshell @ExecCmdRegards,Sathieshkumar. R |
 |
|
|
|
|
|