Question : SQL update by selecting is not working...

I have an update sql statement that is not working in SQL Server 2008. The statement fails to execute on with and invalid column name error. I have tried the syntax several ways and I believe it should be working but doesn't the only working difference between where I can make it work and not is in one instance I use a temporary table.

Can anyone describe what the problem might be?

Thanks,
Matt
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
--this works...

UPDATE Table_1	
SET name =	(SELECT Table_2.toast FROM Table_2 WHERE Table_2.other_id = Table_1.id)
WHERE EXISTS(SELECT Table_2.toast FROM Table_2 WHERE Table_2.other_id = Table_1.id)

--this does not work
UPDATE AddressPhase	
SET FixedCost =	(SELECT #TEMP1.Cost FROM #TEMP1 WHERE #TEMP1.IntAddressPhasesId = AddressPhase.IntAddressPhasesId)
WHERE EXISTS(SELECT #TEMP1.Cost FROM #TEMP1 WHERE #TEMP1.IntAddressPhasesId = AddressPhase.IntAddressPhasesId)

Answer : SQL update by selecting is not working...

IntAddressPhasesId should be IntAddressPhaseId ?
Random Solutions  
 
programming4us programming4us