Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Triggers Question.

Author  Topic 

compound
Starting Member

7 Posts

Posted - 2006-06-07 : 14:31:32
I wrote and update trigger but I have to know what the value of the field was before the update.

For example if I have a table A with the field a then I have to know what a was before the "FOR UPDATE" trigger is fired.

Thank you!

cmdr_skywalker
Posting Yak Master

159 Posts

Posted - 2006-06-07 : 14:37:57
Check out the BOL for triggers (CREATE TRIGGER>T-SQL Ref), you will find a logical (conceptual) tables named DELETED and INSERTED.
You are looking for the DELETED.

May the Almighty God bless us all!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-08 : 04:13:33
If you update the table DELETED table will have the records before updation and INSERTED table will have the records after updation

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

compound
Starting Member

7 Posts

Posted - 2006-06-13 : 16:48:33
Thank you! This works! Awesome!
Go to Top of Page

rokosz
Starting Member

4 Posts

Posted - 2006-06-14 : 00:28:37
Thank you very much too, for that clarification. That actually took some pain out of the evening.

bol talks about their existence (inserted, deleted, and updated) and provides some examples but doesn't clearly state _what_ they are.

for instance: why can't i browse them along with my other tables -- oh, they're in Master? noooo. They're temporary but not in an @@temp way either...
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-06-14 : 01:35:05
"inserted, deleted, and updated"

Really?

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-14 : 02:51:15
They are not available to view as they have structure that depends on the table in which they are defined. And there is no table known as Updated

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -