Question : varchar column1 sort, want to add 'hello'

Column1
1080.5
1080.2
55
30.1
6.5
720i
1366 x 768
1080p



works


but when I add 'hello' to varchar column1
error
1:
2:
3:
4:
5:
6:
7:
SELECT Column1 
FROM YourTable
ORDER BY 
   CASE IsNumeric(Column1)
      WHEN 1 THEN Convert(Numeric(18,2), Column1)
      ELSE 0
   END DESC, Column1 Desc

Answer : varchar column1 sort, want to add 'hello'

Okay, so the values you have listed above work with the code, but when you add the word 'hello' to a column1 in a new row you get an error? Like I said this works fine for me with the word hello, but maybe it is something else going on. If you have data with more than two decimals by the way you might want Numeric(18,4) or choose a more appropriate data type. I just used that as an example!
Random Solutions  
 
programming4us programming4us