Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7601447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:09:57+00:00 2026-05-30T23:09:57+00:00

I have a table with 3 fields [ID, Name, LastUpdated]. LastUpdated has a default

  • 0

I have a table with 3 fields [ID, Name, LastUpdated].
LastUpdated has a default value of “GetDate() so it automatically fills itself when a new record is added.

When I instead run an UPDATE on TABLE, I would like to have this field reset itself to the current GetDate().

CREATE TRIGGER dbo.Table1_Updated
   ON  dbo.Table1
   AFTER UPDATE
AS 
BEGIN
    SET NOCOUNT ON;
    UPDATE dbo.Table1 SET LastUpdated = GETDATE()
END
GO

But because I don’t have a WHERE Clause, ALL records get updated.

QUESTION:
Where would I get the value of the ID of the updated record on a UPDATE Trigger?

Would the fact that I’m updating a field of the table inside the Trigger, re-call a new Trigger event (and so on) ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T23:09:59+00:00Added an answer on May 30, 2026 at 11:09 pm

    From ‘INSERTED’, table INSERTED is common to both the INSERT, UPDATE trigger.

    CREATE TRIGGER dbo.Table1_Updated
    ON dbo.Table1
    FOR INSERT, UPDATE /* Fire this trigger when a row is INSERTed or UPDATEd */
    AS BEGIN
      UPDATE dbo.Table1 SET dbo.Table1.LastUpdated = GETDATE()
      FROM INSERTED
      WHERE inserted.id=Table1.id
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table of firearms in my game, it has 3 fields: Name
I have User table in my DB. A user has the fields name, company_id
I have a product table called products It has 3 fields (name,model(PK), and class_name).
I have a table with fields ID, action and value. ID is the record
I have a table Details It has 2 fields Name and Country . It
I have table options , which have 2 fields ( name and value )
Suppose you have these tables: Table Name: Salesman Fields: S_ID(Primary Key), Name Table Name:
I have a table called Employee with the following fields: EmpID Salary Name I
I have a database table (named Topics) which includes these fields : topicId name
I have a table T with fields id, parentid , name. i make relationship

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.