Singe quote issue.

  • I have a MSRS report that accepts a multi values parameter. The parameter values can have a single quotes as part of the string.

    I create a temp table through the parameters being passed. The code for creatign a table through the parameters is as mentioned below:

    IF (select Count(*) from @tblCustName) <> 0

    BEGIN

    SET @Condition='('

    select @Condition=@Condition+''''+CAST(name AS VARCHAR(50))+''', '

    from @tblCustName

    SELECT @Condition=LEFT(@Condition, LEN(@Condition)-1)+')'

    SELECT @DinamicSQL=@DinamicSQL+' AND oe.name IN ' +@Condition

    END

    @tblCustName = temp table to store the selected paramters in table form

    @Condition = contains the comma separated string from the temp table

    How can i handle the single quote issue so as to get the data on the report as per the parameters being passed.

    Any suggestions to handle this issue. 🙁

    please reply ASAP.

    thanks

  • If I understand you correctly the values stored in the "name" column of the @tblCustName table may contain single quotes. Replace all the single quotes in then "name" values with double single quotes like this:

    select @Condition=@Condition+''''+CAST(replace(name, '''', '''''') AS VARCHAR(50))+''', '

    from @tblCustName

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

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