下图中的亮点显示了我想要实现的逻辑。我意识到语法不正确。5 S" w' m0 h; ~: r5 n
只有当目标表中列出的值为空,源表中的对应值不为空时,才能有条件更新MERGE句子中的记录吗?2 N2 t8 T6 o( f0 Q! X; d% R9 o
如何建议重写? ' S8 |! p) R% S& N8 Y" ~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 7 n+ D* j. Q% h6 T* i 解决方案: $ b4 v2 p! t$ ^: y) T 也许可以用When Matched And (s.[Created Date] Is Not Null And t.[Created Date] IsNull) Then Update ...。