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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Error: Subquery returned more than 1 value.

Author  Topic 

usmansyedali
Starting Member

5 Posts

Posted - 2010-03-01 : 02:46:30
Hello folks,

I am getting the following error. Please help to fix it...


"Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression."

__________________________________________________________________
select 'PREVASSIGN', u.username as userid,

(
select count(*)
from tblmivdet E,tblmivs M, tblbudget b
where e.prjid=b.prjid and e.csicode=b.bcode and E.prjid=542
and E.prjid=M.prjid and E.isno=M.isno and M.issdate<='2009-12-31'
and ltrim(rtrim(isnull(e.csicode,''))) <> '' and u.userid = substring(E.updatedby,1,
case
when charindex('<->', E.updatedby)-1<=0
then 1
else charindex('<->', E.updatedby)-1 end ) and
e.updatedon <
dateadd(day, 0, cast(DATEPART(yyyy, getdate()) as varchar(5)) + '-' + cast(DATEPART(m, getdate()) as varchar(5)) + '-' + cast(DATEPART(d, getdate()) as varchar(5)))
group by substring(E.updatedby,1,charindex('<->',E.updatedby)-1),e.updatedon

)

from users u

________________________________

Regards
Usman

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-03-01 : 02:54:08
it is as what the error message said. Your subquery returns more than 1 row.

Run this by itself and you will see.

select count(*)
from tblmivdet E,tblmivs M, tblbudget b
where e.prjid=b.prjid and e.csicode=b.bcode and E.prjid=542
and E.prjid=M.prjid and E.isno=M.isno and M.issdate<='2009-12-31'
and ltrim(rtrim(isnull(e.csicode,''))) <> '' and u.userid = substring(E.updatedby,1,
case
when charindex('<->', E.updatedby)-1<=0
then 1
else charindex('<->', E.updatedby)-1 end ) and
e.updatedon <
dateadd(day, 0, cast(DATEPART(yyyy, getdate()) as varchar(5)) + '-' + cast(DATEPART(m, getdate()) as varchar(5)) + '-' + cast(DATEPART(d, getdate()) as varchar(5)))
group by substring(E.updatedby,1,charindex('<->',E.updatedby)-1),e.updatedon



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-01 : 10:32:56
isnt this same as

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=140575

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -