Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQL Server 2008 XML路径分隔列表,使用换行符而不是分号_Sql_Reporting Services_Substring - Fatal编程技术网

SQL Server 2008 XML路径分隔列表,使用换行符而不是分号

SQL Server 2008 XML路径分隔列表,使用换行符而不是分号,sql,reporting-services,substring,Sql,Reporting Services,Substring,我有一份SSRS报告,它使用以下查询列出逗号分隔的名称: Select distinct ST2.Country, st2.Location, st2.[Group], substring( ( Select ';'+ST1.[Sponsor] AS [text()] From tbl_de_list ST1 Where ST1.[W ID] = ST2.[W ID]

我有一份SSRS报告,它使用以下查询列出逗号分隔的名称:

Select distinct 
    ST2.Country, st2.Location, st2.[Group], 
    substring(
    (
            Select ';'+ST1.[Sponsor]  AS [text()]
            From tbl_de_list ST1
            Where ST1.[W ID] = ST2.[W ID]            
            For XML PATH ('')
     ), 2, 1000) [sponsor]
From 
    tbl_de_list ST2
order by 
    st2.[W ID]
我需要这是一个新的行时,从ssrs报告导出

这就是我所拥有的:

first name, last name ; first name, last name
我在一列中需要的内容:

first name, last name
first name, last name

在谷歌上做了一些研究之后,我调整了我的查询,添加了一个空格,而不是分号作为分隔符

DECLARE @NewLineChar AS CHAR(2) = CHAR(13) + CHAR(10)
Select distinct ST2.Country, st2.Location,st2.[Group], 
substring(
    (
        Select ';'+ST1.[Sponsor]  AS [text()]
        From tbl_de_list ST1
        Where ST1.[W ID] = ST2.[W ID]            
        For XML PATH ('')
    ), 2, 1000),';',@NewLineChar) [Sponsor]
From tbl_de_list ST2
order by st2.[W ID]

当您将报告导出到excel/csv时,它会被推到新行。

很高兴您找到了答案!别忘了——这将有助于未来的搜索者发现这个问题有一个解决方案。这个问题有48小时的等待时间,所以请在几天后再次检查,然后单击此答案旁边的复选标记。