当前位置:编程学习 > C#/ASP.NET >>

一个sql表中原先有个id字段,是统一4位数的,现在想在4位数前统一加个数字1,该怎么办?谢谢

一个sql表中原先有个id字段,是统一4位数的,现在想在4位数前统一加个数字1,该怎么办?谢谢 --------------------编程问答-------------------- update table set id='a'+id
如果ID是数字
update table set id=convert(int,'123'+convert(varchar(64),id)) --------------------编程问答-------------------- 如果id是字符类型的话update tablename set id = '1' + id
如果id是数字类型的话
update tablename set id = 10000 + id
或使用链接方式,如下
update tablename set id = cast(('1'+cast(id as varchar(5)) as int) --------------------编程问答-------------------- 非常感谢! --------------------编程问答--------------------
引用 1 楼 ViewStates 的回复:
update table set id='a'+id
如果ID是数字
update table set id=convert(int,'123'+convert(varchar(64),id))

正解
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,