Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Guidance on writing a trigger

Author  Topic 

cidr2
Starting Member

28 Posts

Posted - 2009-03-11 : 11:52:07
Hi there,

I need to write a trigger and hope someone can help me a little.

One of my tables (GradePosition) has 5 columns that hold values that represent how many days staff work on a project. So, for example, one column is ProjectManager and the values entered represent how many days the ProjectManager worked on a particular stage of the project.

There is another table (DailyRates) that has two columns, one that holds RatesOfPay. The other column that makes up the row holds IDs that represent the staff position. For example 1 represents a ProjectManager and in the RateOfPay column there will be a Particular amount.



The idea is to set up a trigger that will calculate the first table column multiplied by the second table column RateOfPay.
Something like:
ProjectManager(Days)*RateOfPay WHERE GradePosition=1

The result would go into specific columns of a third table (Costs).

Another problem is that the RateOfPay can change and when it does change there is a column where the most recent date goes for new rates.

The trigger would also have to find the correct rateOfPay where there is the latest Date; something like:

GradePosiiton.[ProjectManager] * DailyRates.[RateOfPay] WHERE DailyRates.[GradePosition] = 1 and MAX(DailyRates.[Date])

Of course, since there's 5 columns, there will be 5 different variables i.e. AssistantDirector and the GradePosition may be 2

Can anyone help me write this.

Thanks for any help.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-11 : 13:35:51
why do you want to write this logic in trigger? you want cost to be recalculated each time when a rate changes?
Go to Top of Page
   

- Advertisement -