Cast String to int and use in Where clause

前端 未结 1 708
盖世英雄少女心
盖世英雄少女心 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)
提交回复
热议问题