Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger for update, insert

Status
Not open for further replies.

athuraliya

IS-IT--Management
Joined
Dec 18, 2001
Messages
2
Location
DE
I want to write a trigger to run on any insert or update so that whatever values inserted, a desired value should be entered to a particular coloumn.
Let's say my table is T1 and it has columns a(number),b(Text),c(DateTime) . I want the trigger force to take GETDATE() value for column c always(on any update or insert) The main problem I have is in the trigger, how do I refer to the record which is being updated or inserted?
Has any body an idea?
Thanks in advance
 
The logical table, Inserted, contains the updated record. You can refer to it as you would any table but only in the context of the Trigger. See the documentation in SQL BOL or at...

Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Yea I know, but as far as I know, we can't change the content of the logical table 'inserted'. I want to make the change I need to the physical record just entered (or updated)
Thanks
 

I assume you physical record has a key or unique identifier. You can get the key columns from the Inserted table and use the keys to update the record. Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top