Click here to Skip to main content
15,908,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

I Get Error When i Execute Query and Error is Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression
So Please Help me

I Give You Code Below-

What I have tried:

DECLARE @Course85 VARCHAR(50)='';
DECLARE @College85 VARCHAR(50)='';
DECLARE @InspectionDate85 VARCHAR(50)='';

SET @Course85=(SELECT CourseName FROM mast_Course WHERE CourseId=@inpCourseCode)
SET @College85=(SELECT CollegeName FROM CollegeMaster WHERE CollegeID=@inpCollegeCode)

SET @InspectionDate85 = (SELECT CONVERT(VARCHAR(11),IESL.DateFrom,103) +'To'+ CONVERT(VARCHAR(11),IESL.DateTo,103) InspectionDate
FROM Inspection_Details IES
INNER JOIN Insp_InspectorEmailStatusLog IESL ON IESL.InspectionId = IES.InspectionId AND IESL.InspectorId=IES.InspectorID
WHERE IES.InspectionId=@inpInspectionId
AND IES.InspectorID=@inpInspectorID
AND IESL.Status IN ('1','5'))


SELECT @Course85 CourseName, @College85 CollegeName,@InspectionDate85 InspectionDate
Posted
Updated 17-Dec-16 22:19pm

Some of your SELECT statements is returning multiple values. The most likely culprit is that one ending with
JavaScript
AND IESL.Status IN ('1','5')
. However, only you can find out the rogue one.
 
Share this answer
 
v4
Use top 1 clause in your sub query to restrict one record at a time Currently your query are like this


SET @Course85=(SELECT CourseName ....)
SET @College85=(SELECT CollegeName FROM CollegeMaster ....)

SET @InspectionDate85 = (SELECT ...)



Change these to by adding Top 1 in each query

SET @Course85=(SELECT Top 1 CourseName ....)
SET @College85=(SELECT Top 1 CollegeName FROM CollegeMaster ....)

SET @InspectionDate85 = (SELECT  Top 1 ...)
 
Share this answer
 

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