1

how to Generate xml file in sql server 2005 using tsql

2 Answers 2

4
Select Emp_Id,Emp_Name from tblEmployee Where Emp_Id < 3
For XML AUTO,ELEMENTS
--For XML [MODE],ELEMENTS

MODE

AUTO, RAW, EXPLICIT

Result [AUTO]

<tblEmployee>
 <Emp_Id>1</Emp_Id>
 <Emp_Name>AAA</Emp_Name>
</tblEmployee>
<tblEmployee>
 <Emp_Id>2</Emp_Id>
 <Emp_Name>BBB</Emp_Name>
</tblEmployee>

Result [RAW]

Above Xml with Instead of <tblEmployee> here..... <ROW> and </tblEmployee> is </ROW>

Sign up to request clarification or add additional context in comments.

Comments

1

Stored proc exec DBName.dbo.Table is

select * from table for xml path 
SET @SQL= 'bcp "exec DBName.dbo.Table" queryout c:\myfile.xml -w -r -t -SServerName -T'
EXEC Master..xp_CmdShell @SQL 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.