高位舍去。用*2不行,会报溢出错。
有什么简单的方法?

解决方案 »

  1.   


    declare @x int=12345select cast(substring(cast(@x as varchar),2,100) as int) resultresult
    -----------
    2345
      

  2.   

    T-sql里有位操作,先去掉最高位,再乘以2
    假设是个8bit的数字,先和0111 1111做位与(&)然后乘2
      

  3.   

    smallint 型update dbo.testtable set test = (test & 127) * 2;
      

  4.   

    是不是varchar类型的呢?是不是说截取