SQL Server compare values of two rows of same table and get not matching column names -


i need compare 2 rows (inserted & deleted) of same table , compare values. , need not matching columns. inside trigger.

here i've tried far 've no idea of how compare these 2 rows , column names contains different values .

select *  inserted inner join deleted d on d.purchasingdocitemno = i.purchasingdocitemno                       , d.purchasingdocno = i.purchasingdocno                      , d.referencedocumentno = i.referencedocumentno                      , d.productno = i.productno 

change select :

select -- each column you're checking.  account isnull if need case when i.col1 = d.col1 0 else 1 end col1changed....... inserted inner join deleted d on (i.<pk> = d.<pk>) 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -