?
Solved

SQL Trigger Problem Urgent 500 points

Posted on 2007-04-10
3
Medium Priority
?
245 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 1000 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 1000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

777 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