Sql-Server

MERGE 與 MERGE INTO 有什麼區別?

  • February 14, 2022

MERGE 與 MERGE INTO 有什麼區別?

每個的案例是什麼?

令人驚訝的是,我找不到任何關於這種差異的現有問題。

MERGE的文件也沒有解釋這一點,而且它只在一個似乎與該差異無關的情況下使用一次(如果有的話)。

MERGE的語法圖:

[ WITH <common_table_expression> [,...n] ]  
MERGE
   [ TOP ( expression ) [ PERCENT ] ]
   [ INTO ] <target_table> [ WITH ( <merge_hint> ) ] [ [ AS ] table_alias ]  
   USING <table_source> [ [ AS ] table_alias ]
   ON <merge_search_condition>  
   [ WHEN MATCHED [ AND <clause_search_condition> ]  
       THEN <merge_matched> ] [ ...n ]  
   [ WHEN NOT MATCHED [ BY TARGET ] [ AND <clause_search_condition> ]  
       THEN <merge_not_matched> ]  
   [ WHEN NOT MATCHED BY SOURCE [ AND <clause_search_condition> ]  
       THEN <merge_matched> ] [ ...n ]  
   [ <output_clause> ]  
   [ OPTION ( <query_hint> [ ,...n ] ) ]
;  

表示這[ INTO ] 是可選的。就像INSERT一樣,它是否存在都沒有任何區別。

引用自:https://dba.stackexchange.com/questions/307488