我有一个表,其中一个字段是JSON字符串。
“CX.UW.001”:“03/08/2017”,“CX.UW.001.AUDIT”:“admin”,
我想制作一份SSRS报告,其中的可读格式如下:
mapconcat
有可能吗?
答案 0 :(得分:0)
右键点击该字段,选择expression
,从Text
类别找到Common Functions
,使用Replace
功能,语法应如下:
Replace (Fields!Yours.Value.Value,"""","")
或者在TSQL中:
Select Replace(JSON_COLUMN,'"','')
From table
答案 1 :(得分:0)
如果您正在寻找多个记录,几乎任何解析/拆分功能都可以,或者您可以使用简单的CROSS APPLY与一点XML一起使用
Declare @YourTable table (ID int, JSON varchar(max))
Insert Into @YourTable values
(1,'"CX.UW.001": "03/08/2017", "CX.UW.001.AUDIT": "admin"')
Select A.ID
,DisplayAs = replace(B.RetVal,'"','')
From @YourTable A
Cross Apply (
Select RetSeq = Row_Number() over (Order By (Select null))
,RetVal = LTrim(RTrim(B.i.value('(./text())[1]', 'varchar(max)')))
From (Select x = Cast('<x>' + replace((Select replace(A.JSON,',','§§Split§§') as [*] For XML Path('')),'§§Split§§','</x><x>')+'</x>' as xml).query('.')) as X
Cross Apply x.nodes('x') AS B(i)
) B
<强>返回强>
ID DisplayAs
1 CX.UW.001: 03/08/2017
1 CX.UW.001.AUDIT: admin
或者如果您想要包装字符串
Select A.ID
,DisplayAs = replace(replace(JSON,',',char(13)),'"','')
From @YourTable A
<强>返回强>
1 CX.UW.001: 03/08/2017
CX.UW.001.AUDIT: admin