SQL MERGE CASE UPDATE multiple columns -
i appreciate on following issue. trying on sql server 2012.
i trying use merge statement update column has had change rather perform update on whole row.
when update performed on column want date modified column updated well.
merge dbo.tablea target
using
( select * dbo.dbo.tableb ) sourceon ( target.id = source.id , target.name = source.name )
when matched then
update set
target.age =
case when target.age!= source.age
then source.age else target.age
end
-- want update 'date_modified' column if case statement has made modification age column ,
target.address =
case when target.address != source.address
then source.address else target.address
end
-- want update 'date_modified' column if case statement has made modification address column ;
is there way can update 'date_modified' field within case statement?
thank you,
Comments
Post a Comment