Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SubQuery Returned more than 1 value error

Status
Not open for further replies.

sanctified

Programmer
Mar 9, 2006
65
GB
Hi Group,
I'm getting the following error in my SP when the tblHolidayDates has more than one record. Here is my SP:
begin

if datediff(day,getdate()-10 ,(Select HolidayDate from tblHolidayDates))= 3 AND
DATEPART(dw,(select holidaydate from tblHolidayDates)) = 1 -- Monday Date
SELECT su.SuspensionID, su.ConsentNo, si.SiteID,
si.NameNo + ' ' + si.Address1 AS SiteAddress, si.SiteDesc,
si.SuspensionStart, si.SuspensionEnd, si.Address1, si.BaysAttached,
rd.RefValue AS NoticeDays, si.MergeID
FROM Suspension su
INNER JOIN SiteData si ON su.SuspensionID = si.SuspensionID
INNER JOIN RefData rd ON si.NotReq = rd.RefCode
WHERE su.Status = 'ACT'
and si.Archived = 'N'
and (datediff(day, getdate()-10 , si.SuspensionStart) = rd.RefValue
OR (datediff(day, (Select holidaydate from tblHolidayDates), si.SuspensionStart)= rd.RefValue + 2)
or datediff(day,(Select holidaydate from tblHolidayDates), si.SuspensionStart)=rd.RefValue + 1)
end

Any pointers much appreciated.
 
sub queries can return back only one value:

>>if datediff(day,getdate()-10 ,(Select HolidayDate from tblHolidayDates))=


wht is the logic there? are u checking for ALL the dates that have a difference of more than 3 days???

Known is handfull, Unknown is worldfull
 
Yes,however this should ever only return ONE value as:

1: the field is keyed
2: I'm comparing against the current date (yes I know maybe the parser is not syntax intelligent but surely 1 should allow for this select statement?)

thanks
 
>>Select HolidayDate from tblHolidayDates

>>Yes,however this should ever only return ONE value as:

how? does the table tblHolidayDates has only ONE entry???

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top