merge(insert update 同時)

  • 186
  • 0
  • 2018-05-30

 merge

https://docs.microsoft.com/zh-tw/sql/t-sql/statements/merge-transact-sql?view=sql-server-2017

https://blog.csdn.net/yuzhic/article/details/1896878

 

if exists(select 1 from T where T.a='1001' ) update T set T.b=2 Where T.a='1001' else insert into T(a,b) values('1001',2);