473,396 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 2572
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

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

Similar topics

3
by: Alejandro | last post by:
Hi! I have no experience at all using triggers, and I don't even know very well SQL server. I hope someone can help me with the folling: I need to know if it is possible to implement a trigger that...
6
by: Scott CM | last post by:
I have a multi-part question regarding trigger performance. First of all, is there performance gain from issuing the following within a trigger: SELECT PrimaryKeyColumn FROM INSERTED opposed...
2
by: R. Rajesh Jeba Anbiah | last post by:
I have Googled a lot, but couldn't still find the answer... I could see, I can trigger the "click" event like: button_object.Click() But, I need to trigger the onChange() of select options. I...
1
by: Barbara Lindsey | last post by:
I am a postgres newbie. I am trying to create a trigger that will put a copy of a record into a backup table before update or delete. As I understand it, in order to do this I must have a...
10
by: Anton.Nikiforov | last post by:
Dear all, i have a problem with insertion data and running post insert trigger on it. Preambula: there is a table named raw: ipsrc | cidr ipdst | cidr bytes | bigint time | timestamp...
18
by: Bill Smith | last post by:
The initial row is inserted with the colPartNum column containing a valid LIKE pattern, such as (without the single quotes) 'AB%DE'. I want to update the column value with the results of a query...
0
by: JohnO | last post by:
Thanks to Serge and MarkB for recent tips and suggestions. Ive rolled together a few stored procedures to assist with creating audit triggers automagically. Hope someone finds this as useful as...
1
by: Gregi | last post by:
Hello, I'm using VS2005 and SQL 2005. Is it possible for a SQL trigger to immediately raise an event in my C# program? Actually it's C++/CLI, but it's easy to translate C# -C++/CLI, so any...
4
by: Joerg Gempe | last post by:
Hello, I've a problem where some data gets updated but I don't know which process (SP) is responsible for it (it's an old installation which I've taken over). Is it somehow possible to know...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.