Solved

SQL Trigger Problem Urgent 500 points

Posted on 2007-04-10
3
243 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

730 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