Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2010-05-05 : 10:32:07
|
I receive the below message when attempting to run the below query (which is actually a view). I know returning more than 1 value is not allowed. Any suggestions on how to get this to work within a view?"Msg 512, Level 16, State 1, Line 1Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression."select c.sym, c.company, e.first + ' ' + e.last as account_manager, chkho = (select cc.company from company ccinner join ps_bridge psbb on psbb.co_id = cc.co_idinner join product pp on pp.pro_id = psbb.pro_idwhere pp.pro_id = 001and psbb.ho_co_id = cc.co_id),chkhostate = (select cc.state_ from company ccinner join ps_bridge psbb on psbb.co_id = cc.co_idinner join product pp on pp.pro_id = psbb.pro_idwhere pp.pro_id = 001and psbb.ho_co_id = cc.co_id)from company cinner join employee e on e.employee_id = c.account_manager_idinner join ps_bridge psb on psb.co_id = c.co_idinner join product p on p.pro_id = psb.pro_idwhere p.pro_id = 001 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-05-05 : 10:37:09
|
Just this should do, no?select c.sym, c.company, e.first + ' ' + e.last as account_manager , c.company, c.statefrom company cinner join employee e on e.employee_id = c.account_manager_idinner join ps_bridge psb on psb.co_id = c.co_idinner join product p on p.pro_id = psb.pro_idwhere p.pro_id = 001 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-05-05 : 14:47:53
|
| you've an extra join with employee in main query so not sure if given suggestion is same as your original, but you can get a start from it------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|