I have a query like this:
UPDATE t3
SET somevalue = (SELECT t2.id
FROM table1 t1
JOIN table2 t2
ON t1.fk_table2_id = t2.id
WHERE t3.id = t1.fk_table3_id)
FROM table3 t3
The subquery SELECT t2.id FROM table1 t1 JOIN table2 t2 … returns 2+ values at some place in my SQL Server 20008 DB. Is there an easy way to figure out where it fails? Or is there another way to update a column in one table with values from another?
Thanks in advance
Assuming
ts.idis unique, you can find out where its returning more then 1 row, use a SELECT (omit thetable3from the query ift1.fk_table3_idreally is a foreign key constraint):