/*
generate xml fragment for RDCMANAGER groups
run this scrript on hcimon
*/

USE [ControlCenter]


DECLARE @tpl VARCHAR(max)='      <server>
        <properties>
          <displayName>@ou@ - @name@</displayName>
          <name>@dns@</name>
        </properties>
      </server>
';


SELECT 
    e.[EN_designation]
    , s.[SE_designation]
    , s.[SE_DNS]
    --,s.*
    , REPLACE(REPLACE(REPLACE(@tpl, '@name@',[s].[SE_designation] ), '@dns@',[s].[SE_DNS]),'@ou@', [s].[SE_OU_code] ) AS fragment
FROM [dbo].[Server] s
    JOIN [dbo].[Entity] e ON e.[EN_id] = s.[SE_entity]
WHERE [e].[EN_designation] IN (
    --'Amavita'
    --'Coop-Vitality'
    'Sun Store'
)
ORDER BY [e].[EN_designation], [s].[SE_designation]