Avatar of akiles99
akiles99
Flag for India

asked on 

Trigger for date

Hi guys,
I need to write a trigger on mssql...The scenario is pretty simple.

I have two tables namely customer & dealer...

Customer has the following columns

ondate datetime
rectype varchar(20)
etc...

Dealer has the follwing columns
ULSTORDAGE varchar(20)
etc...

Now what i need is when i insert or update a row in table customer the trigger has to fire.

sales activity means the rectype='S'.

Trigger:To populate the field with the number of days since the last sales activity of the
contact record.
How:
This will come from the  table (Customer) as the total number of days elapsed since their
last order or sales activity, in reverse, from today. This would be adjusted for each day going
forward and will require an automatic update each day.
Using a RecType Code of S and the ONDATE field as the evaluation field.
Update the Dealer table in column named ULSTORDAGE.


I mean ondate value difference(the date going to be inserted/updated & the previous last sales date)
has to be stored in ULSTORDAGE.

Cheers...
akiles
Microsoft SQL Server 2005Microsoft Excel

Avatar of undefined
Last Comment
akiles99

8/22/2022 - Mon