Better you go for dynamic sql.Suppose you have a department table which has 2 columns(Id, Name)
The code is as follows
declare @Id int = 3;
declare @sql nvarchar(max) = 'SELECT Id,Name FROM Departments';
IF @Id = 2
SET @sql += ' WHERE Id='+ cast(@id as varchar(10));
EXEC sp_ExecuteSQL @sql;