Solved

SQL Trigger Problem Urgent 500 points

Posted on 2007-04-10
3
242 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

860 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