It's hard to explain, but I'll provide an example. Lets say I have the following table:
PolicyNo ClientNo Name
-------- -------- ----
123 1 John
123 2 Sally
ABC 3 Alice
ABC 4 Bob
And I'd like to use TSQL and "FOR XML" to group information under similar Policy Nos, like the following:
<root>
<Policy>
<PolicyNo> 123 </PolicyNo>
<ClientInfo>
<ClientNo> 1 </ClientNo>
<Name> John </Name>
</ClientInfo>
<ClientInfo>
<ClientNo> 2 </ClientNo>
<Name> Sally </Name>
</ClientInfo>
</Policy>
<Policy>
<PolicyNo> ABC </PolicyNo>
<ClientInfo>
<ClientNo> 3 </ClientNo>
<Name> Alice </Name>
</ClientInfo>
<ClientInfo>
<ClientNo> 4 </ClientNo>
<Name> Bob </Name>
</ClientInfo>
</Policy>
</root>