Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Last Modified Expand / Collapse
Author
Message
Posted Tuesday, August 4, 2009 10:43 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, February 16, 2011 8:25 AM
Points: 24, Visits: 54
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,
Post #764993
Posted Tuesday, August 4, 2009 10:48 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 10:20 AM
Points: 12,927, Visits: 32,332
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #764997
Posted Tuesday, August 4, 2009 12:08 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, February 16, 2011 8:25 AM
Points: 24, Visits: 54
Very neat! Thanks.
Post #765055
Posted Friday, July 13, 2012 10:12 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, July 23, 2012 12:11 AM
Points: 2, Visits: 3
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
Post #1329726
Posted Monday, July 16, 2012 2:18 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 7:17 AM
Points: 2,682, Visits: 4,745
geidy_killer89 (7/13/2012)
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


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.



Kingston Dhasian

How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1329977
Posted Monday, July 23, 2012 12:10 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Monday, November 24, 2014 4:53 AM
Points: 3,422, Visits: 5,368
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 mantra: No loops! No CURSORs! No RBAR! Hoo-uh!

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?
Since random numbers are too important to be left to chance, let's generate some!
Learn to understand recursive CTEs by example.
Splitting strings based on patterns can be fast!
Post #1333605
Posted Monday, July 23, 2012 12:13 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, July 23, 2012 12:11 AM
Points: 2, Visits: 3
The problem was with the Delimitator :) now It works... thank u 4 replay
Post #1333607
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse