把int转换成char(10),不足10位前补0,怎么写脚本? 前面有过的,飘香的写法update tblset field2=RIGHT(CAST(Power(15,10)+field1 as varchar),10) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 update table1 set field2=right('0000000000'+convert(varchar(10),field1),10) update table1 set field2=right('0000000000'+convert(varchar(10),field1),10) update table1 set field2=right('0000000000'+convert(varchar(10),field1),10) 编号: 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) update table set field=replicate('0',10-len(cast(field as varchar))+cast(field as varchar)当然,你的字段应该在10位长度之内. Insert into select 导数据时 提示列名无效? 关于IDENTITY列的问题 求一条Sql语句,在线等..!! 经典SQL语句,来者有分... LogExplorer连接问题 MSSQL关于int转换成datetime的问题 麻烦高手看看哦!谢谢 求助IIS Virtual Directory Management for Sql Server 怎么配 大家救命啊,我受不了了!!! 为什么作业的状态是正在执行,但没有更新数据表的内容? SQL Server2K 定時發送mail 如何用sql语句在win2000建立登陆用户??
内容 版主,超过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)
cast(field as varchar)当然,你的字段应该在10位长度之内.