Groups | Blog | Home
all groups > sql server (alternate) > july 2004 >

sql server (alternate) : Does SQL Server support XML Functions


addverma NO[at]SPAM netscape.net
7/30/2004 6:19:22 AM
Hi,
Do any versions of SQL Server support the following functions, as
they appear in the Oracle Database:-

1) XMLElement
2) XMLAttributes
3) XMLForest

Thanks in Advance for your reply
Bye
Erland Sommarskog
7/30/2004 9:15:23 PM
Amardeep Verma (addverma@netscape.net) writes:
[quoted text, click to view]

Since I don't know Oracle, I don't know what these functions do. It is
not likely that SQL Server supports these functions directly, but it
may support the same functionality. You would need to explain what these
functions do to get answer.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
addverma NO[at]SPAM netscape.net
8/2/2004 12:10:21 AM
Hi,
Thanks Erland for your Response. These Functions take simple
SELECT statement and return the result in a XML format. With each
Column name as a tag and the value in that column as the data.
For Example the Employee Table of NorthWind Database has 3
columns:-
1) EmpNo
2) EmpLastName
3) EmpFirstName
Then using the below mentioned functions we can get the output
<EMP>
<EMPNo>1</EMPNo>
<EMPFirstName>ABC</EMPFirstName>
<EMPLastName>XYZ</EMPLastName>
</EMP>

Hope this helps
Amardeep Verma

[quoted text, click to view]
Erland Sommarskog
8/2/2004 9:47:57 AM
Amardeep Verma (addverma@netscape.net) writes:
[quoted text, click to view]

It looks like you should study the FOR XML clause in the SELECT statement.
It gives you several possibilities. Rather than typing examples here,
I refer you to Books Online myself, since I am no XML wizard myself.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
drmcl NO[at]SPAM drmcl.free-online.co.uk
8/4/2004 2:53:27 PM
SQL sever has a few ways to generate xml. An example below that
conforms to your spec(ie columns as elements) can be viewed in QA

select * from employees
where employeeid=1 for xml auto, elements

NOTE: it is best run when the query is set to 'Results in text' and
also
AddThis Social Bookmark Button