Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Update trigger - why it works?
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01291246
Message ID:
01291508
Views:
7
This message has been marked as a message which has helped to the initial question of the thread.
>Hi Borislav,
>
>The first line in the Using Nested Triggers answered my question
>An AFTER trigger does not call itself recursively unless the RECURSIVE_TRIGGERS database option is set.
>
>So, since I didn't change this setting and use its default value, it worked.
>
>However, I guess, this is not a save approach.
>
>Is there any other way to change value in the field of a table when another field is changed? Say, in my case I want to always set Drop_Date to current date if I set status to 'D'.
>
>This was just an exercise, but I'd like to understand the concept.
>
>Thanks again for your help.

You could use Trigger but you should check IF Status field is updated and IF you have 'D' in that updated field:
.....
IF UPDATED('Status') AND
   EXISTS (SELECT * FROM Updated WHERE Status = 'D')
   BEGIN
       --- Do updates of the  Drop_Date field here
   END
...
(not tested)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform