Hi there! I'm trying to use like operator with optional clause in my query by referring to this link. I'm getting the error - "Incorrect syntax near '('." How do I solve this ?
-- query
DECLARE @Name varchar(50)
SELECT @Name = [[(SELECT TOP 1 Name FROM Employees WHERE Name LIKE "%"{{Name}}"%") -- ]] NULL
EXEC Demo_GetEmployees @Name = @name
-- SSMS profiler
DECLARE @Name varchar(50)
SELECT @Name = (SELECT TOP 1 Name FROM Employees WHERE Name LIKE "%"("dbo"."Employees"."Name" like @P0)"%") -- NULL
EXEC Demo_GetEmployees @Name = @name',N'@P0 nvarchar(4000)',N'%An%'