I am nervous to pull the trigger on this query, as I have not tooled around with subqueries all that much. I wanted to make sure this beastie does what I want it to do in terms of my program.
DoCmd.RunSQL ("UPDATE Gage_Master SET Gage_Master.Est_Calibration_Cost = SELECT dbo_Gage_Master.Est_Calibration_Cost FROM dbo_Gage_Master WHERE dbo_Gage_Master.Est_Calibration_Cost <> Gage_Master.Est_Calibration_Cost WHERE Gage_Master.Gage_ID = dbo_Gage_Master.Gage_ID;")
Basically – will this puppy update the Estimated Calibration Cost in the Gage_Master table (linked to another program’s MDB datastore with a table by the same name) with the value in the SQL-Server stored copy of the Gage_Master table (dbo_Gage_Master) as long as they are not equal?
Sorry if this is an already asked question – like I said, this is a pretty complex thing, and the last thing I want to do is blank out my prices in my production database because I wrote something wrong. Thanks in advance for your help!
I’m assuming you’re trying to run this in Access. This would explaing the “Missing Operator” error you’ve referred to in comments–Access doesn’t understand
UPDATE...FROM.... Try this instead:Yeah, it looks like you might be updating the wrong way, because
dgmcomes first in the join (it just worked out that way…). That’s not the case, as it’s theSETclause that determines what updates actually get done.