I am trying to use the below query to check if the field is numeric . Based on which i am doing orderby in SQL query.
select * from [dbo].[tablename]
ORDER BY col1,
ISNUMERIC(replace(col2,'T','')),
CASE WHEN ISNUMERIC(replace(col2,'T','')) = 1 THEN CONVERT(INT, replace(col2,'T','')) ELSE 0 END,
replace(col2,'T','')
Error i am getting
TEIID31100 Parsing error: Encountered "THEN CONVERT([*]INT[*], replace" at line 7, column 71
The parser is complaining that the convert syntax is incorrect. It should be argument, then type - convert(replace(col2,'T'), INT).
Also isnumeric isn't one of our built-in functions. Do you have it as a UDF?