Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 trigger update problem?

Author  Topic 

akpaga
Constraint Violating Yak Guru

331 Posts

Posted - 2012-12-17 : 10:51:45
Hi friends

I have table called Customers

CustomerName,Customer_Purchase_Date,Customer_Pay_Date

and Then I have a trigger for it after Update to insert values into

Customer_Audit
CustomerName,Customer_Purchase_Date_New,Customer_Purchase_Date_Old,Customer_Pay_Date_New,Customer_Pay_Date_OLd,


The problem now is that
When the Customer_Purchase_Date for Customer is changed the the old -new values for the Customer_Pay_Date should not change but they are changing and then at one point old and new values are becoming equal in the audit table.


Same is the Case with Customer_pay_Date . If it changes in CUstomer_Table i want to update only the old and new fields of Customer_Pay_Date in the new row of the audit table..


Hope I am clear..Please excuse me if i did not put it nicely...

bitsmed
Aged Yak Warrior

545 Posts

Posted - 2012-12-17 : 11:27:13
I usually make "before update" triggers - have you tried this?
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-12-17 : 14:59:42
Can you post yout trigger code? My guess is you are getting the column from the wrong "special" table (inserted/deleted).
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-12-19 : 01:04:12
do you mean to say you've separate columns to hold old and new values in audit table?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -