Cast String to int and use in Where clause

前端 未结 1 709
盖世英雄少女心
盖世英雄少女心 2021-01-14 13:30

How to convert string field and use for Where clause.Am getting exception like this please help to find the wrong thing.

select * from student 
where (cast (         


        
1条回答
  •  伪装坚强ぢ
    2021-01-14 13:54

    Compare only when is numeric

    select * from student 
    where 
      (
      case when ISNUMERIC( linerevnum ) 
      then cast (linerevnum as int)
      else null
      end  ) = 1
    

    or simple:

    select * from student 
    linerevnum = '1'
    

    0 讨论(0)
提交回复
热议问题