Solved

SQL Trigger Problem Urgent 500 points

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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 set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

747 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

13 Experts available now in Live!

Get 1:1 Help Now