How to use Like Operator with VARIABLE

  • I want to apply like Operator in my searching time. but i dont use it before with variable. anyone pls help me to slove this.

    Ex SELECT *

    FROM Product

    WHERE (CategoryID = @CategoryId) AND (Keywords Like @Category)

  • try this;

    Declare @Keywords varchar(50)

    set @Keywords = 'YourString'

    SELECT *

    FROM Product

    WHERE (CategoryID = @CategoryId) AND

    (Keywords Like '%' + @Keywords + '%' )

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

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