I'm getting the below error message when I compile the query:
Error : An expression of non-boolean type specified in a context where a condition is expected, near ')'.
Query:
Select * from EPLMethods SP WHERE EPLMEthodId=@EplMethodId
AND
(
CASE WHEN (ISNULL(SP.Data.value('(/*/subject)[1]', 'bit'), 0)= 1 AND ISNULL(SP.Data.value('(/*/answers)[1]', 'nvarchar(max)'), '') = '')
THEN 1
ELSE
Case WHEN (SELECT COUNT (*) FROM dbo.GetEPLData3(@EplMethodId, 1, SP.Data.value('(/*/Answers/AnswersList/Entry[@key="number"]/value)[1]', 'nvarchar(max)')))> 0 Then
1
ELSE
0
END
END
)
Just add = 1
behind the CASE
's closing END
.
Select * from EPLMethods SP WHERE EPLMEthodId=@EplMethodId
AND
(
CASE WHEN (ISNULL(SP.Data.value('(/*/subject)[1]', 'bit'), 0)= 1 AND ISNULL(SP.Data.value('(/*/answers)[1]', 'nvarchar(max)'), '') = '')
THEN 1
ELSE
Case WHEN (SELECT COUNT (*) FROM dbo.GetEPLData3(@EplMethodId, 1, SP.Data.value('(/*/Answers/AnswersList/Entry[@key="number"]/value)[1]', 'nvarchar(max)')))> 0 Then
1
ELSE
0
END
END
= 1
)
As the error states, you're trying to use a number where the SQL Server expects a boolean - unlike some other languages, there is no implicit conversion from number to logical value in SQL Server, so you have to convert it yourself.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.