Solved

SQL Trigger Problem Urgent 500 points

Posted on 2007-04-10
3
239 Views
Last Modified: 2010-03-19
Code is part of a Trigger.
TblCost has a field called GradeID if the GradeID =  6 i would like         SET TotalCost = A.Total * B.Rate                      to be                     SET TotalCost = 1 * B.Rate
with in the code below.


UPDATE A
SET TotalCost = A.Total * B.Rate
FROM TblTimeEntry A
INNER JOIN TblCost B ON   B.CostId = A.CostRateId
INNER JOIN Inserted I ON A.ProjectEntryID = I.ProjectEntryID
0
Comment
Question by:ellandrd
3 Comments
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 18882811
Hello ellandrd

What's the problem? From the post I cannot understand what do you intend to do and what's "SQL Trigger Problem "

!i!
0
 
LVL 6

Accepted Solution

by:
chiragkhabaria earned 250 total points
ID: 18882812
UPDATE A
SET TotalCost = Case When  GradeID =  6  Then A.Total * B.Rate Else  1 * B.Rate  End
FROM TblTimeEntry A
INNER JOIN TblCost B ON   B.CostId = A.CostRateId
INNER JOIN Inserted I ON A.ProjectEntryID = I.ProjectEntryID
Authored by: ellandrd
0
 
LVL 6

Assisted Solution

by:Gokulm
Gokulm earned 250 total points
ID: 18882819
UPDATE A
SET TotalCost =
     CASE GradeID
              WHEN 6 THEN 1 * B.Rate
              ELSE A.Total * B.Rate
     END
FROM TblTimeEntry A
INNER JOIN TblCost B ON   B.CostId = A.CostRateId
INNER JOIN Inserted I ON A.ProjectEntryID = I.ProjectEntryID
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now