Hi everyone,

I'm trying to run a query to get a XML result set using 'for
xml'.

A simple example say I have the following query:
SELECT DepartmentName, EmployeeID
FROM Employees employee JOIN Departments department
ON Employees.DepartmentID=Departments.DepartmentID
ORDER BY 1, 2
FOR XML

In something like iAnywhere I could use FOR XML AUTO and get
something that looks like this (which is what I want):
<department DepartmentName="Finance">
<employee EmployeeID="148"/>
<employee EmployeeID="390"/>
<employee EmployeeID="586"/>
...
</department>
<Department name="Marketing">
<employee EmployeeID="184"/>
<employee EmployeeID="207"/>
<employee EmployeeID="318"/>
...
</department>

But when I run the above query using Sybase ASE 15 I get a
result set that looks like
<row>
<DepartmentName>Finance</DepartmentName>
<EmployeeID>148</EmployeeID>
</row>
<row>
<DepartmentName>Finance</DepartmentName>
<EmployeeID>390</EmployeeID>
</row>
...
<row>
<DepartmentName>Marketing</DepartmentName>
<EmployeeID>184</EmployeeID>
</row>
<row>
<DepartmentName>Marketing</DepartmentName>
<EmployeeID>207</EmployeeID>
</row>
... etc

How can I get Sybase ase to give me something like the first
example with a parent/child entity relationship?

Thanks,
NW