April 15, 2015 at 7:38 am
Hi All,
I'm missing something here.
What I am trying to recreate is:
<value version="5" type="database">
<name>master</name>
<server>servername</server>
<integratedSecurity>True</integratedSecurity>
<connectionTimeout>15</connectionTimeout>
<protocol>-1</protocol>
<packetSize>4096</packetSize>
<encrypted>False</encrypted>
<selected>True</selected>
<cserver>ServerAlias</cserver>
</value>
with this query:
SELECT
'version="5" type="database"' AS 'value',
'master' AS 'name',
LTRIM(RTRIM(([Server Name]))) AS 'server',
'True' AS 'integratedSecurity',
15 AS 'connectionTimeout',
4096 AS 'packetSize',
'False' AS 'encrypted',
'True' AS 'selected',
LTRIM(RTRIM(([Server Name]))) AS 'cserver'
FROM dbo.RedGateServerList
FOR XML PATH('value'), ELEMENTS
BUt my output is not correct, it is creating this:
<value>
<value>version="5" type="database"</value>
<name>master</name>
<server>ServerName</server>
<integratedSecurity>True</integratedSecurity>
<connectionTimeout>15</connectionTimeout>
<packetSize>4096</packetSize>
<encrypted>False</encrypted>
<selected>True</selected>
<cserver>ServerAlias</cserver>
</value>
So my question is how to I get <value>version="5" type="database"</value>
as the first 'value' node?
I've tried multiple ways, but no success.
Thanks in advance
April 15, 2015 at 7:42 am
SELECT '5' AS 'value/@version',
'database' AS 'value/@type',
'master' AS 'value/name',
LTRIM(RTRIM(( [Server Name] ))) AS 'value/server',
'True' AS 'value/integratedSecurity',
15 AS 'value/connectionTimeout',
4096 AS 'value/packetSize',
'False' AS 'value/encrypted',
'True' AS 'value/selected',
LTRIM(RTRIM(( [Server Name] ))) AS 'value/cserver'
FROM dbo.RedGateServerList
FOR XML PATH(''), ELEMENTS;
Produces: -
<value version="5" type="database">
<name>master</name>
<server>RAWR</server>
<integratedSecurity>True</integratedSecurity>
<connectionTimeout>15</connectionTimeout>
<packetSize>4096</packetSize>
<encrypted>False</encrypted>
<selected>True</selected>
<cserver>RAWR</cserver>
</value>
April 15, 2015 at 7:46 am
Thanks for the response.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply