in my optional parameter query that uses LIKE operator , Escape special characters is not working . this is part of the query
NAME LIKE CASE WHEN % +@Name+ % IS NULL THEN NAME ELSE % +@Name+ % END
i) 认为,
NAME LIKE CASE WHEN % +@Name+ % ESCAPE IS NULL THEN NAME ELSE % +@Name+ % END
but when i add escape but it raise an error . any help ??
《刑法》:
set @Name= Restaur[ant
SELECT [JOB].HOUSE_CODE, [JOB].JOB_CODE, [JOB].OPEN_DATE, [JOB].NAME AS Position, [JOB].DESCRIPTION, [RESTAURANT].ZIP_CODE AS ZipCode,
[STATE].STATE_NAME AS State, [RESTAURANT].CITY_NAME AS City
FROM [JOB] INNER JOIN
[RESTAURANT] ON [JOB].HOUSE_CODE = [RESTAURANT].HOUSE_CODE INNER JOIN
[STATE] ON [RESTAURANT].STATE_CODE = [STATE].STATE_CODE INNER JOIN
[JOB_CODE] ON [JOB].HOUSE_CODE = [JOB_CODE].HOUSE_CODE AND [JOB].JOB_CODE = [JOB_CODE].JOB_CODE AND
[RESTAURANT].HOUSE_CODE = [JOB_CODE].HOUSE_CODE
WHERE ( [JOB].NAME LIKE CASE WHEN % +@Name+ % IS NULL THEN [JOB].NAME ELSE % +@Name+ % END ESCAPE )