SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 trigger update problem?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

akpaga
Constraint Violating Yak Guru

USA
310 Posts

Posted - 12/17/2012 :  10:51:45  Show Profile  Reply with Quote
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...


Edited by - akpaga on 12/17/2012 10:52:49

bitsmed
Constraint Violating Yak Guru

277 Posts

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

Lamprey
Flowing Fount of Yak Knowledge

4361 Posts

Posted - 12/17/2012 :  14:59:42  Show Profile  Reply with Quote
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

India
52249 Posts

Posted - 12/19/2012 :  01:04:12  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000