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 ) source

on ( 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

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -