sql - How to check for details of subquery output? -


i have query this:

update t3 set    somevalue  = (select t2.id                     table1 t1                          join table2 t2                            on t1.fk_table2_id = t2.id                    t3.id = t1.fk_table3_id)   table3 t3  

the subquery select t2.id table1 t1 join table2 t2 ... returns 2+ values @ place in sql server 20008 db. there easy way figure out fails? or there way update column in 1 table values another?

thanks in advance

assuming ts.id unique, can find out returning more 1 row, use select (omit table3 query if t1.fk_table3_id foreign key constraint):

select t3.id, count(*)  table1 t1 join table2 t2 on t1.fk_table2_id = t2.id   join table3 t3 on t3.id = t1.fk_table3_id group t3.id having count(*) > 1 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -