前面有过的,飘香的写法
update tbl
set field2=RIGHT(CAST(Power(15,10)+field1 as varchar),10)

解决方案 »

  1.   

    update table1 set field2=right('0000000000'+convert(varchar(10),field1),10)
      

  2.   

    update table1 set field2=right('0000000000'+convert(varchar(10),field1),10)
      

  3.   

    update table1 set field2=right('0000000000'+convert(varchar(10),field1),10)
      

  4.   

    编号: 68 发送者 foolishchao 发送时间 2002-7-8 15:48:31 删除  回复  
    内容 版主,超过3次,贴不上。
    http://www.csdn.net/Expert/TopicView1.asp?id=858385执行 select Power(15,10)服务器: 消息 232,级别 16,状态 3,行 1
    发生类型 int 的算术溢出错误,值 = 576650390625.000000。改为
    update table1 set field2=right(cast(Power(cast(10 as bigint),11)+field1 as varchar),10)
    或者
    update table1 set field2=right(cast(10000000000+field1 as varchar),10)
    或者
    update table1 set field2=right(REPLICATE('0',10)+convert(varchar(10),field1),10)
     
      

  5.   

    update table set field=replicate('0',10-len(cast(field as varchar))+
    cast(field as varchar)当然,你的字段应该在10位长度之内.