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

WPF: binding viewmodel property of type DateTime to Calendar inside ItemsControl -

java - Getting corefrences with Standard corenlp package -

jQuery clickable div with working mailto link inside -