An expression of non-boolean type specified in a context where a condition is expected, near ','

  • I am getting the error message, "An expression of non-boolean type specified in a context where a condition is expected, near ',' "

    when running an ssrs 2008 r2 report.

    The sql embedded in the dataset is:

    IF @reportID <> 0

    BEGIN

    SELECT 'Students report 1' AS selectRptName, 1 AS rptNumValue

    UNION

    SELECT 'Students report 2', 2

    UNION

    SELECT 'Students report 3', 3

    UNION

    SELECT 'Students report 4', 4

    UNION

    SELECT 'Students report 5', 5

    ORDER BY selectRptName

    END

    )

    The sql runs fine in managment studio when I declare @reportID.

    The sql runs fine with I comment out 'IF @reportID <> 0'.

    The @reportID is a parmeter value that is passed to the applicable dataset.

    The @reportID can have more than one value.

    Thus can you show me sql and/or tell me what I need to do to solve the issue for me?

  • What's the purpose of the IF statement? Everything worked fine until I put that in there. Can you base the report on a stored procedure so that the evaluation of the IF statement happens in SSMS, not in SSRS?

  • The purpose is for the user to select 0, 1 or up to 200 subreports.

    Thus I am thinking of calling the following following function to split out the parameter values:

    FUNCTION [dbo].[fn_splitString]

    (

    @listString VARCHAR(MAX)

    )

    RETURNS TABLE WITH SCHEMABINDING

    AS

    RETURN

    (

    SELECT SUBSTRING(l.listString, sn.Num + 1, CHARINDEX(',', l.listString, sn.Num + 1) - sn.Num - 1) _id

    FROM (SELECT ',' + LTRIM(RTRIM(@listString)) + ',' AS listString) l

    CROSS JOIN dbo.sequenceNumbers sn

    WHERE sn.Num < LEN(l.listString)

    AND SUBSTRING(l.listString, sn.Num, 1) = ','

    )

    GO

    Can you show me sql code on how to remove the @reportID <> 0 t-sql above and replace by calling the fn_splitString

    function?

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply