Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

What is SQL server bulk copy utility and how to use it to export data to XML file?

user-image
Question added by Ahmed Abouzaid , Senior Software Engineer / .Net / Outsystems , Emaratech
Date Posted: 2013/09/08
Ahmed Abouzaid
by Ahmed Abouzaid , Senior Software Engineer / .Net / Outsystems , Emaratech

SELECT 

emp.Name ,

emp.Salary + emp.extras as Total

FROM dbo.Employee emp 

FOR XML AUTO,TYPE, ELEMENTS ,ROOT('Salaries')

 

--result will apeare in SQL server management studio

 

--to export it to physical drive you must put this query in BCP like this

--put this query to BCP and replace "localhost" with your server name and replace path or file name

 

BCP "SELECT 

emp.Name ,

emp.Salary + emp.extras as Total

FROM dbo.Employee emp

FOR XML AUTO,TYPE, ELEMENTS ,ROOT('Salaries')" 

QUERYOUT "C:\Salaries.XML" -c -t -T -S localhost -- your path and your server name

 

More Questions Like This