SQL2000 复制 xml 路径('')
Sql2000 replicate for xml path('')
我正在尝试在 SQL 2000 中复制以下代码,它没有 FOR XML PATH('').
select '"Footer",' + stuff((SELECT ',' + '"' + server + '"'
FROM servers
FOR XML PATH ('')),1,1,'')
输出为-
"Footer","MyServer1","MyServer2","MyServer3"
我能得到的最接近的是下面的代码,但输出缺少每个服务器名称周围的引号。
declare @result varchar(max)
select @result = COALESCE(@result + ', ', '') + server
from servers
select '"Footer",' + @result
输出为-
"Footer",MyServer1,MyServer2,MyServer3
只需将引号放在表达式中:
declare @result varchar(max);
select @result = COALESCE(@result + ', ', '') + '"' + server + '"'
from servers;
select '"Footer",' + @result;
我正在尝试在 SQL 2000 中复制以下代码,它没有 FOR XML PATH('').
select '"Footer",' + stuff((SELECT ',' + '"' + server + '"'
FROM servers
FOR XML PATH ('')),1,1,'')
输出为-
"Footer","MyServer1","MyServer2","MyServer3"
我能得到的最接近的是下面的代码,但输出缺少每个服务器名称周围的引号。
declare @result varchar(max)
select @result = COALESCE(@result + ', ', '') + server
from servers
select '"Footer",' + @result
输出为-
"Footer",MyServer1,MyServer2,MyServer3
只需将引号放在表达式中:
declare @result varchar(max);
select @result = COALESCE(@result + ', ', '') + '"' + server + '"'
from servers;
select '"Footer",' + @result;