troubleshooting Question

Trigger for experts only

Avatar of akiles99
akiles99Flag for India asked on
Microsoft SQL Server 2005
5 Comments1 Solution184 ViewsLast Modified:
Hello guys,
I have two tables namely conthist and contact2....
I need a trigger when a insert or update in done on conthist it fires the trigger and the values of the column duration in conthist is stored in UYTD column of contact2....COnthist table also has a column named ondate where  sales date are going to be stored...But with more modifications thats why i'm posting this to experts like you...see more details below...

YTD Sales - Trigger name
Purpose: To populate the field with the amount of the year to date sales activity of the contact record.
How: This will come from the history table (ContHist) as the total amount of the last years sales
activity. This would be adjusted for each year going forward and will require the zeroing out of
the data at the turn of the year. This existing data, in UYTD, would be move to the ULYRSALES
on the first day of the new year.
Using a RecType Code of S and the DURATION field as the amount.
Update the UDF of Contact2 named UYTD
Note: There will be more than one sale item on any given date, as the items are entered into the database
as single line items; but all on one quote/order. You must be able to aggregate the total amount of
the sales and display that aggregated total in the UYTD field...

If a set of sales occured before 1/1/2008, then it would not be part of this year to
date sales....
According to the specs, the data would move to the ULYRSALES field
when the System date turned past 1/1/2009 .

ALso in same trigger i need a nested onewhich increment up by 1 day every day that lapse past the last
sale date....

Daniel Wilson

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros