I have complex query where i am having a varchar variable. I need to perform various operation on it based on the datatype of data i receive in that variable.
If varchar variable contains numeric value then i need to convert it to numeric datatype so i can perform > < operation on it.
It all works fine except below part
Declare @testVal as varchar(50)='ok'
select CASE WHEN IsNUMERIC(@testVal)=1 THEN Cast(@testVal as numeric) ELSE 'n' End
Above query gives me error "Error converting data type varchar to numeric."
I can't use try_convert and advanced functions like that as i am using older version of SQL.