Update s
Set s.ServiceDeliverySettingID =
Case
When s.HCCMRRServiceType = '01' Then (Select ServiceDeliverySettingID from [DSDW].[Dim].[ServiceDeliverySetting]
Where HCCValue = '08')
When s.HCCMRRServiceType in ('02','10') Then ( Select ServiceDeliverySettingID from [DSDW].[Dim].[ServiceDeliverySetting]
Where HCCValue = '01')
When s.HCCMRRServiceType = '06' Then (Select ServiceDeliverySettingID from [DSDW].[Dim].[ServiceDeliverySetting]
Where HCCValue = '97')
When s.HCCMRRServiceType in ('08','11') Then ( Select ServiceDeliverySettingID from [DSDW].[Dim].[ServiceDeliverySetting]
Where HCCValue = '10')
When s.HCCMRRServiceType = '14' Then (Select ServiceDeliverySettingID from [DSDW].[Dim].[ServiceDeliverySetting]
Where HCCValue = '05')
When s.HCCMRRServiceType = '51' Then (Select ServiceDeliverySettingID from [DSDW].[Dim].[ServiceDeliverySetting]
Where HCCValue = '06')
When s.HCCMRRServiceType = '50'
Then
case
when s.InterventionCode = 'ICR' then ( Select ServiceDeliverySettingID from [DSDW].[Dim].[ServiceDeliverySetting]
Where HCCValue = '97')
when s.InterventionCode = 'RC' then ( Select ServiceDeliverySettingID from [DSDW].[Dim].[ServiceDeliverySetting]
Where HCCValue = '06')
when s.InterventionCode = 'ICFCH' then ( Select ServiceDeliverySettingID from [DSDW].[Dim].[ServiceDeliverySetting]
Where HCCValue = '02')
End
From [DSDW].[Staging].[HCCMRRBuildService] s
第15行,第15行,状态1,第33行 关键字“From”附近的语法不正确。
当我执行上述更新查询时,有人可以帮我解释一下我收到错误消息的原因吗?
答案 0 :(得分:3)
您缺少END
Update s
Set s.ServiceDeliverySettingID =
Case
When s.HCCMRRServiceType = '01' Then (Select ServiceDeliverySettingID from [DSDW].[Dim].[ServiceDeliverySetting]
Where HCCValue = '08')
When s.HCCMRRServiceType in ('02','10') Then ( Select ServiceDeliverySettingID from [DSDW].[Dim].[ServiceDeliverySetting]
Where HCCValue = '01')
When s.HCCMRRServiceType = '06' Then (Select ServiceDeliverySettingID from [DSDW].[Dim].[ServiceDeliverySetting]
Where HCCValue = '97')
When s.HCCMRRServiceType in ('08','11') Then ( Select ServiceDeliverySettingID from [DSDW].[Dim].[ServiceDeliverySetting]
Where HCCValue = '10')
When s.HCCMRRServiceType = '14' Then (Select ServiceDeliverySettingID from [DSDW].[Dim].[ServiceDeliverySetting]
Where HCCValue = '05')
When s.HCCMRRServiceType = '51' Then (Select ServiceDeliverySettingID from [DSDW].[Dim].[ServiceDeliverySetting]
Where HCCValue = '06')
When s.HCCMRRServiceType = '50'
Then
case
when s.InterventionCode = 'ICR' then ( Select ServiceDeliverySettingID from [DSDW].[Dim].[ServiceDeliverySetting]
Where HCCValue = '97')
when s.InterventionCode = 'RC' then ( Select ServiceDeliverySettingID from [DSDW].[Dim].[ServiceDeliverySetting]
Where HCCValue = '06')
when s.InterventionCode = 'ICFCH' then ( Select ServiceDeliverySettingID from [DSDW].[Dim].[ServiceDeliverySetting]
Where HCCValue = '02')
END --<-- this was missing
End
From [DSDW].[Staging].[HCCMRRBuildService] s
答案 1 :(得分:1)
首先看,你有一个嵌套的CASE,但我只看到一个END。您需要再添加一个END来完成父CASE语句集。