Based on your example:
SELECT *
FROM TABLE X
WHERE (CASE
WHEN ISNUMBERIC(@parameter_value) = 1 THEN x.id
ELSE x.name
END) = @parameter_value
...would work, I'd like to stress that the approach is not sargable--it won't perform as well as it should.
If dealing with a single parameter, using an IF ELSE would perform better:
IF ISNUMERIC(@parameter_value) = 1
BEGIN
SELECT x.*
FROM TABLE x
WHERE x.id = @parameter_value
END
ELSE
BEGIN
SELECT x.*
FROM TABLE x
WHERE x.name = @parameter_value
END
The other alternative (which should definitely be considered if dealing with more than one filter criteria) is to use dynamic SQL. I recommend reading The curse and blessings of dynamic SQL before looking at this SQL Server 2005+ example:
DECLARE @paramater_value NVARCHAR(255)
DECLARE @SQL NVARCHAR(4000)
SET @SQL = 'SELECT x.*
FROM TABLE x '
SET @SQL = @SQL + CASE
WHEN ISNUMBERIC(@paramater_value) = 1 THEN
' WHERE x.id = @paramater_value '
ELSE
' WHERE x.name = @paramater_value '
END
BEGIN
EXEC sp_executesql @SQL,
N'@paramater_value NVARCHAR(255)',
@paramater_value
END