469,643 Members | 1,947 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

Trigger to find specific New Value

parshupooja
159 100+
Hey All,

I have table A which has 20 columns. I want to create trigger on table A which should get triggered whenever someone tries to update any value in Table A than trigger should insert new as well old value in table B. For ex:

Table B
PK Oldvalue NewValue
1 Brown Blonde

I don't want to insert all columns values instead I want to know what specific column has been changed. if two values are changed than I will insert two record for each value.

any help will be appreciated.
thanks
Feb 26 '08 #1
1 2454
ck9663
2,878 Expert 2GB
Hey All,

I have table A which has 20 columns. I want to create trigger on table A which should get triggered whenever someone tries to update any value in Table A than trigger should insert new as well old value in table B. For ex:

Table B
PK Oldvalue NewValue
1 Brown Blonde

I don't want to insert all columns values instead I want to know what specific column has been changed. if two values are changed than I will insert two record for each value.

any help will be appreciated.
thanks

Inside your trigger:
1. Check what columns were updated. Use this function.

2. Insert the old value of the column from the deleted table.

3. Insert the new value of the column from the inserted table.

Consider doing this in a single transaction.

-- CK
Feb 27 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Alejandro | last post: by
6 posts views Thread by Scott CM | last post: by
2 posts views Thread by R. Rajesh Jeba Anbiah | last post: by
1 post views Thread by Barbara Lindsey | last post: by
10 posts views Thread by Anton.Nikiforov | last post: by
18 posts views Thread by Bill Smith | last post: by
reply views Thread by JohnO | last post: by
1 post views Thread by Gregi | last post: by
4 posts views Thread by Joerg Gempe | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.