下图中的亮点显示了我想要实现的逻辑。我意识到语法不正确。% M! x! I0 z# U3 y. C
只有当目标表中列出的值为空,源表中的对应值不为空时,才能有条件更新MERGE句子中的记录吗? / ^$ |0 B# x2 I- P如何建议重写?3 |0 f; Y9 U' T% ?+ X
MERGE 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 2 I. v+ v; y6 l5 H, u7 P" X解决方案: . x5 R9 Y& s* e( ~ 也许可以用When Matched And (s.[Created Date] Is Not Null And t.[Created Date] IsNull) Then Update ...。