Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Default value trigger
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00810601
Message ID:
00810698
Views:
14
Im definatly not a trigger guru, but in my experience, I suggest you use the update() function instead of the updated_columns() function. I have had nothing but problems with updated_columns().

if update(date) or update(jour_heure)

Its also alot eaiser to understand.

>I'm new with triggers in SQL Server....
>
>In table PUNCH, I have 3 columns: DATE (datetime), JOUR_HEURE (datetime) and DATE_PAYE (datetime). Obviously the table has more than 3 columns ;-)
>
>I want to have the value of DATE_PAYE derived from DATE and JOUR_HEURE when an INSERT or an UPDATE is fired agains that table.
>
>The rule is: IF JOUR_HEURE is before 5AM (the date portion is irrelevant), the DATE_PAYE should be DATE - 1 DAY, ELSE DATE_PAYE = DATE.
>
>I'm thingking of using a trigger (other ways ???) and I want the trigger to fire (on updates) only when IF DATE or JOUR_HEURE changes (USING COLUMNS_UPDATED, since DATE and )
>
>Here is my starting point:
>
>CREATE TRIGGER punch_maj_date_paye ON Punch
>FOR INSERT, UPDATE
>
>AS
> /* On vérifie si les colonnes 3 ou 4 on ete modifiees (Date et jour_heure) */
> IF (COLUMNS_UPDATED() & 12) > 0
> BEGIN
> IF JOUR_HEURE ....
>
> END
>GO
>
>
>Thanks
Previous
Reply
Map
View

Click here to load this message in the networking platform