尝试为 SQL Reporting Services 数据库的目录表中列出的每个报告获取逗号分隔的参数列表:
WITH cte AS (
SELECT
[Path], [Name], CreationDate, ModifiedDate,
CAST(parameter AS XML) AS parameter
FROM [dbo].[Catalog] AS c
)
SELECT [Path], [Name], CreationDate, ModifiedDate, COALESCE(p.nodes('./Name'))
FROM cte AS c
LEFT JOIN c.Parameter.nodes('/Parameters/Parameter') AS T ( p )
ORDER BY c.[Path]
在 BOL 中,它说 COALESCE 用于返回第一个非空值,但我读过它可用于逗号分隔返回的值表。