Using Variable in PATINDEX keyword

  • I am using sql6.5

    Can I use a Variable such as @NAME inside of a PATINDEX statement in a SPROC? For example something like below:

    @NAME varchar(30)

    SELECT EXAMINER_ID

    FROM USER_GROUP

    WHERE PATINDEX('%@NAME%',EXAMINER_ID) > 0

    If so do I need the single quotes or the percentage signs?

    Kevin-

    Thanks For your continued Help.


    Thanks For your continued Help.

  • This would work:

    DECLARE @NAME varchar(30)

    SELECT EXAMINER_ID

    FROM USER_GROUP

    WHERE PATINDEX('%' + @NAME + '%',EXAMINER_ID) > 0

    Michael

  • Thanks, that worked perfectly....

    Thanks For your continued Help.


    Thanks For your continued Help.

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

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