By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,856 Members | 2,163 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,856 IT Pros & Developers. It's quick & easy.

How to identify the ID of row which has been modified?

P: 25
Hi all,

I have table Demo:

Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE Demo
  2. (
  3. ID               int              PRIMARY KEY,
  4. Name         char(50),
  5. BeModified  int             DEFAULT(0)
  6. )
Whenever [Name] is updated, [BeModified] will be set to 1.

I think I should create an TRIGGER AFTER UPDATE

Expand|Select|Wrap|Line Numbers
  1. CREATE TRIGGER UpdateRow
  2.  
  3. ON Demo
  4.  
  5. AFTER UPDATE
  6.  
  7. UPDATE Demo
  8.  
  9. Set BeModified = 1 WHERE ID = "???"
  10.  
My problem is I do not know how to identify the ID of row which has been modified.

Have you got any suggestion for me?

Thank you so much!
Dec 13 '09 #1

✓ answered by ck9663

Use the DELETED and INSERTED tables.

Happy Coding!!!

--- CK

Share this Question
Share on Google+
3 Replies


ck9663
Expert 2.5K+
P: 2,878
Use the DELETED and INSERTED tables.

Happy Coding!!!

--- CK
Dec 13 '09 #2

P: 25
I am sorry to bother you but could you explain it more specific?

I did something to understand more about inserted & deleted table, but I get the message "Invalid object name 'inserted'."
Dec 14 '09 #3

P: 25
I did it, just by using inserted table.

Thanks for your helping!
Dec 14 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.