We help IT Professionals succeed at work.
Get Started

Help with update with join

gogetsome
gogetsome asked
on
300 Views
Last Modified: 2012-08-13
Hello, i need some help with the following statement

UPDATE #TempMyDCR
SET MileageAmountPaid =  (E.MileageTotal * (SELECT M.CostPerMile FROM Mileage AS M, Jobs AS J , Timesheets AS T WHERE M.ClientID = J.ClientID  AND      J.JobNumber = T.JobNumber       AND T.TimeSheetId in (Select TimesheetId From #TempMyDCR)))
FROM [Expenses] AS E Join #TempMyDCR AS D
On D.TimeSheetID = E.TimeSheetID

Grateful for any help!


I'm getting the following error:
Msg 512, Level 16, State 1, Line 2
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.

Most likely the result of this:
(E.MileageTotal * (SELECT M.CostPerMile FROM Mileage AS M, Jobs AS J , Timesheets AS T WHERE M.ClientID = J.ClientID  AND      J.JobNumber = T.JobNumber       AND T.TimeSheetId in (Select TimesheetId From #TempMyDCR)))
Comment
Watch Question
Software Engineer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 2 Answers and 4 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE