SQL Server Return rowId after update Trigger

Hey SQL Experts

I need help creating a "on Update Trigger "for a given table  . Is it possible to return the Primary key rowID of a row in my Customer table.
I do not have access to the ASPx page that invokes the table update.
Example: if Customer's phone number has changed, I want to know the ROWID for this customer so that I may update a related table.
scubamikeyAsked:
Who is Participating?
 
chapmandewConnect With a Mentor Commented:
the inserted table is almost like a temporary table that gets created as a result of the update.  In this case, the inserted table contains an exact replica of the structure of the table that was update, and contains the newest values (the newly updated values).  There is also a deleted table that you could use that would be exactly like the inserted table (rows, structure, etc), but it contains the OLD values (the values before the update).  So, if you updated 5 rows, the inserted would have 5 rows w/ the new values, the deleted table would have 5 rows w/ the old values.
0
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
in the trigger, you have the full row data in the INSERTED table, which includes the primary key field.
can you clarify what you are missing, actually?
0
 
chapmandewConnect With a Mentor Commented:
This is a bad way to do what you're needing, but here goes (note that this will return multiple records if > 1 is updated)

create trigger triggername on tablename
after update
as
begin
select primarykeyfield
from inserted  --inserted is the actual name, you don't need to change this.
end
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
scubamikeyAuthor Commented:
Thanks, Is the INSERTED estblished for a ROW that has been Updated??
0
 
scubamikeyAuthor Commented:
I Did not now that Thanks
0
 
scubamikeyAuthor Commented:
know that..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.