Contains use on Dynamic Parameters

  • Hi All,

    how to use Contains function on sql parameters?

    If Sql parameter has space then its not working else working.

    e.g

    If @searchParam='serachtext' then its working but if its @searchParam='serach text' then not working

    kindly provide solution.

    Thanx

  • Could you give more information?

    How about sample data so we can reproduce what you're trying to do?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Something like this?

    DECLARE @searchParam VARCHAR(100);

    SET @searchParam = 'search text';

    IF @searchParam LIKE '% %'

    BEGIN

    PRINT 'Not Working'

    END

    ELSE

    BEGIN

    PRINT 'Working'

    END;

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

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