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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need the ID for the changed rec in the trigger

Status
Not open for further replies.

gcole

Programmer
Aug 2, 2000
390
US
I need to pull a field from the changed record in the table so I can pass it to the sp that is execucuted with the trigger. How can I get this information?
 
The new values are available from the inserted table in the trigger.

======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
How do I know which record has been changed? In other words, I want the value in the Rec_ID field from the changed record.
 
If this is an Update or Insert trigger than the rec_id will be in the inserted table and will be called rec_id. For example:

SELECT REC_ID
FROM INSERTED

This will give you the rec_id's of the records that have been changed.

If this is a DELETE trigger it will be in the deleted table.

SELECT REC_ID
FROM DELETED

SQL uses these tables. I kind of think of them as #TEMP tables that are at the system level.

Hope this helps,
SQLRickster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top