I have the following code which allows using a variable within an IN clause:
DECLARE @Ids varchar(50);
SET @Ids = '24,25';
SELECT *
FROM table
WHERE ','+@Ids+',' LIKE '%,'+CONVERT(VARCHAR(50),id_field)+',%';
Since @Ids is an optional field which can be null, how would I modify the code such that it incorporates
(@Ids IS NULL OR id_field = @Ids)