SSRS:“包含错误:[BC302205]语句结尾应为预期值。”

时间:2018-10-19 11:27:20

标签: reporting-services replace expression reporting

我创建了一个嵌套的replace表达式,它将根据当前值更改字段中的字符串。我几乎可以正常工作,但是我不确定在结束该声明时需要添加什么。有人可以帮忙吗?

 =Replace(
Replace(
REPLACE (Fields!DeviceType.Value, "1", "Desktop / Laptop / Server"),
"2", "Server"),
"3", "Printer"),
"4", "Firewall"),
"5", "Managed Switch"),
"6", "Switch"),
"7", "Access Point Controller"),
"8", "Access Point"),
"9", "Desk Phone"),
"10", "Modem"),
"11", "Mobile Phone"),
"12", "DVR"),
"13", "Camera"),
"14", "NAS / SAN"),
"15", "PBX"),
"16", "UPS"),
"17", "Router"),
"18", "Monitor"),
"19", "Docking Station")

2 个答案:

答案 0 :(得分:1)

many to many函数将一个文本替换为字符串中的另一个文本,因此create unique nonclustered index idx_MenuParentID on MenuItem(ID, ParentID) where ParentID is not null; 将返回“手机”。您的情况不是您需要REPLACE功能。

理想情况下,您将有一个数据库表可以连接并从那里获取描述,但是我假设您由于某种原因不能这样做。

因此,您需要的是SWITCH功能。

REPLACE

如果某些数据未包含在表达式中,则最终表达式的作用类似于=REPLACE("Mobile Phone", "Mobile", "Cell")

如果这不起作用,请检查是否没有前导/尾随空格。如果有,那么您将需要使用TRIM(=SWITCH ( Fields!DeviceType.Value = "1", "Desktop / Laptop / Server", Fields!DeviceType.Value = "2", "Server", Fields!DeviceType.Value = "3", "Printer", Fields!DeviceType.Value = "4", "Firewall", Fields!DeviceType.Value = "5", "Managed Switch", Fields!DeviceType.Value = "6", "Switch", Fields!DeviceType.Value = "7", "Access Point Controller", Fields!DeviceType.Value = "8", "Access Point", Fields!DeviceType.Value = "9", "Desk Phone", Fields!DeviceType.Value = "10", "Modem", Fields!DeviceType.Value = "11", "Mobile Phone", Fields!DeviceType.Value = "12", "DVR", Fields!DeviceType.Value = "13", "Camera", Fields!DeviceType.Value = "14", "NAS / SAN", Fields!DeviceType.Value = "15", "PBX", Fields!DeviceType.Value = "16", "UPS", Fields!DeviceType.Value = "17", "Router", Fields!DeviceType.Value = "18", "Monitor", True, "Unknown Device Type")

还要检查该字段是否为文本,如果它实际上是数字,请删除数字周围的引号。

答案 1 :(得分:0)

如果您的表达式看起来不错,但您仍然在处理此错误,则建议检查错误消息中引用的对象上的其他表达式,或者完全删除您的表达式并尝试保存。

我在可见的可见性表达式上收到了相同的错误。问题原来是多余的“”),但令人沮丧的是,错误消息说这是我三遍检查过的tablix可见性表达式,一切都很好,结果却是行可见性表达式。