下图中的亮点显示了我想要实现的逻辑。我意识到语法不正确。 * h6 _8 I" S k只有当目标表中列出的值为空,源表中的对应值不为空时,才能有条件更新MERGE句子中的记录吗? & Q% {4 \" o0 ~3 U' s5 F u& W如何建议重写? ! g2 [' o9 K o4 cMERGE dbo.input_311 AS [t]USING dbo.input_311_staging AS <strike>ON ([t].[unique key] = <strike>.[unique key])WHEN NOT MATCHED BY TARGET THEN INSERT(t.[Created Date]) VALUES(s.[Created Date])WHEN MATCHED THEN UPDATE SET(t.[Created Date] = s.[Created Date] WHERE s.[Created Date] IS NOT NULL AND t.[Created Date] IS NULL)OUTPUT deleted.*,$action,inserted.*;GO ( v5 x9 k3 g! G5 g9 \ E; Q) }2 h) D 解决方案: 1 g( i# J/ u D, `0 v
也许可以用When Matched And (s.[Created Date] Is Not Null And t.[Created Date] IsNull) Then Update ...。