Parameter Problem

  • Hi,

    I have a query which is returning the values based on parameter.

    If i give the following query it is returning the values successfully.

    select * from externalBrands where extbName like '%^[7 Diamonds !!! !^]%' Escape '^'

    but if i give the query like this, it is returning zero rows.

    declare @STR varchar(50)

    set @STR =  '''%^[7 Diamonds !!! !^]%'' Escape ''^'''

    print @STR

    select * from externalBrands where extbName like @STR

    When i check the @STR, the value of @STR is '%^[7 Diamonds !!! !^]%' Escape '^'

    So, when i pass the string directly to the query, i am getting rows, but if i pass thru variable, i am getting the zero rows.

    Please let me know the actual reason?

    Thanks in advance.

    Regards

    Thirumalaraj

     

     

     

  • The ESCAPE cannot be within the string passed to LIKE it must be outside e.g.

    set @STR =  '%^[7 Diamonds !!! !^]%'

    where extbName like @STR Escape '^'

    Far away is close at hand in the images of elsewhere.
    Anon.

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

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