August 4, 2009 at 10:43 am
I am working on a project that will require the transfer of thousands of records from one DB to another. I need to add a new column (LastModified) (Date/Time) to capture the last time a record was modified so I can go back and reconcile the data. Assistance with a trigger to do that is much appreciated.
Best,
August 4, 2009 at 10:48 am
heres a generic example; if you post your actual table definition, we could tailor the example to your actual table:
Create Trigger TableName_Update On TableName For Update As
Update Tb
Set tb.date_modified = GetDate()
From TableName Tb
Join Inserted i on Tb.PKColumn = i.PKColumn
Lowell
August 4, 2009 at 12:08 pm
Very neat! Thanks.
July 13, 2012 at 10:12 pm
my database [sahia] the table [carti] i want to automaticaly change the [datead] field , with the curent date
when i insert or update a record. I've tried but did not work
July 16, 2012 at 2:18 am
geidy_killer89 (7/13/2012)
my database [sahia] the table [carti] i want to automaticaly change the [datead] field , with the curent datewhen i insert or update a record. I've tried but did not work
Welcome to SQL Server Central !!!
Please do not post your problems in other threads.
Create a new thread of your own and post the code of the trigger you are using along with some explanation of what you are trying to do.
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
July 23, 2012 at 12:10 am
geidy_killer: Thread hijacking issues aside, you may find the information you seek in this forum post: http://www.sqlservercentral.com/Forums/Topic1332707-392-1.aspx
Look for answers in it from Kingston and me.
My thought question: Have you ever been told that your query runs too fast?
My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
Since random numbers are too important to be left to chance, let's generate some![/url]
Learn to understand recursive CTEs by example.[/url]
[url url=http://www.sqlservercentral.com/articles/St
July 23, 2012 at 12:13 am
The problem was with the Delimitator 🙂 now It works... thank u 4 replay
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply