以下select語句正常工作。在UPDATE查詢中使用select sub
SELECT *
FROM [VoiceflexBilling].[dbo].[FEBU17_OWH07579_Calls - TEST] A
WHERE EXISTS (SELECT 1
FROM [BillingReferenceData].[dbo].[CLIMapping] B
WHERE A.CustomerCLI = B.CLI AND A.CustomerCLI = '84422881')
然而,當我把它包在一個CASE語句,如下
UPDATE [VoiceflexBilling].[dbo].[FEBU17_OWH07579_Calls - TEST]
SET [VoiceflexBilling].[dbo].[FEBU17_OWH07579_Calls - TEST].[CustomerCLI] =
CASE WHEN
SELECT *
FROM [VoiceflexBilling].[dbo].[FEBU17_OWH07579_Calls - TEST] A
WHERE EXISTS (SELECT 1
FROM [BillingReferenceData].[dbo].[CLIMapping] B
WHERE A.CustomerCLI = B.CLI AND A.CustomerCLI = '84422881'))>1
THEN 'X' ELSE 'Y' END
它失敗,出現以下錯誤
「只有一個表達式可以在選擇列表中指定當子查詢不與EXISTS一起引入「
我猜它應該是'select count(*)'... Select *返回一個結果集,然後嘗試將它與一個標量值進行比較...... –