In a stored procedure I want to add an AND statement to the query depending on the value of a variable.
DECLARE @name as varchar(50)
SET @name = ''
SELECT * FROM Tabla T
WHERE T.campo = 'valor'
Here I would like to add an AND statement to the query depending on the value of @name. If it is not empty, add the statement
AND T.Name like '%'+ @name + '%'