mysql - update tables data from updated table - using merge-sql server and my sql -


i have 2 tables @ least 25 columns.

  1. customers
  2. updated_customers

the columns names same.

every day have changes in columns added, deleted , changed want use merge update customers (target table) updated_customers (source table).

merge code is:

merge customers trg using  ( select      [customerid]     ,[type]     ,[first_name]     ,[last_name]     ,[email]     ,[phone]     ,[sale_status]     ,[verification]     ,[campname] updated_customers ) src  on src.[ customerid] =trg.[ customerid]   when matched update set     trg.[ customerid]=src.[ customerid]     ,trg.[ type]=src.[ type]     ,trg.[ first_name]=src.[ first_name]    ,trg.[ last_name]=src.[ last_name]     ,trg.[ email]]=src.[ email]]     ,trg.[ phone]=src.[ phone]     ,trg.[ sale_status]=src.[ sale_status]     ,trg.[ verification]=src.[ verification]     ,trg.[ campname]=src.[ campname]    when not matched insert(trg.[customerid],trg.[ type]…) values(src.[ customerid],src.[type]…);  end   merge customers trg using  ( select      distinct [customerid]     updated_customers) src      on src.[customerid] =trg.[customerid]       when not matched     insert(customerid, …..)     values(src.[customerid],…));     end 

how can columns @ once?

check changes in row-

if nothing changed – nothing.

if changed – update changes , mark in way.

if added (that not problem).

i have @ least 10 tables same.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -