Error converting data type varchar

前端 未结 8 1512
既然无缘
既然无缘 2020-12-20 15:07

I currently have a table with a column as varchar. This column can hold numbers or text. During certain queries I treat it as a bigint column (I do

8条回答
  •  抹茶落季
    2020-12-20 15:24

    Try changing your view to this :

    SELECT TOP 100 PERCENT ID, 
    Cast(Case When IsNumeric(MyCol) = 1 Then MyCol Else null End AS bigint) AS MyCol
    FROM MyTable
    WHERE (IsNumeric(MyCol) = 1)
    

提交回复
热议问题