Place wildcard holder either side of an input parameter?

  • Hi All,

    I need to place a wilecard % either side of an input parameter within the body of a stored procedure to use in the where clause.

    What is the best way to do this?

    Thanks

  • If you mean for working with LIKE, then ...

    SET @ParameterName = '%' + @ParameterName + '%'

  • ... where SomeColumnName LIKE '%' + @ParameterName + '%'


    Everything you can imagine is real.

  • Keep in mind that if the SomeColumnName LIKE '%' + @ParameterName + '%' is the only criteria in your where clause, this will result in a table scan.

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

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

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