Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Update trigger - why it works?
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01291246
Message ID:
01291508
Vues:
8
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform