Click here to Skip to main content
15,904,153 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi everyone,
I am getting this error:
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
please help, I have tried to solve it on my own but still can't find the right answer..
this is the query:
update tbl_M_MasterLogs set rptprobtype =
(Select [Problem Type]
from tbl_rpt_MasterData
where tbl_M_MasterLogs.CaseNo = tbl_rpt_MasterData.CaseNo)
Thank you very much in advance!
Posted

by the way can you explain to me why "TOP 1"?
Thank you again genius! :-D
 
Share this answer
 
Comments
Corporal Agarn 4-Mar-11 15:22pm    
TOP 1 gives you only one result. Your sub query returned more that one result thus the error.
serigraphie 4-Mar-11 16:05pm    
Hi I have another one though, the "top 1" is not working when it comes to id's :(
Oh my holy GOD! thank you so much!!!!!
 
Share this answer
 
Add TOP 1 to sub query is my quick answer.

SQL
update tbl_M_MasterLogs set rptprobtype =
(Select TOP 1 [Problem Type]
from tbl_rpt_MasterData
where tbl_M_MasterLogs.CaseNo = tbl_rpt_MasterData.CaseNo)


The other way would be
SQL
update tbl_M_MasterLogs 
set rptprobtype = tbl_rpt_MasterData.[Problem Type] 
FROM tbl_M_MasterLogs 
INNER JOIN tbl_rpt_MasterData
ON tbl_M_MasterLogs.CaseNo = tbl_rpt_MasterData.CaseNo)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900