大家好:
数据库中某表中有字段tcardid,比如有值5101000100125010220100311001,
其中510100(区域号)01001250102(流水号)20100311(时间)001(序号),现在要改变这个值,
把流水号中的前两位‘01’去掉,变为‘001250102’, 在'序号'之前加上两个字符‘00’,变为
'00001',最后更新为
510100 001250102 20100311 00001
由于tcardid值很多,手改不行,想问问能不能用sql语句解决?谢谢各位了!
数据库中某表中有字段tcardid,比如有值5101000100125010220100311001,
其中510100(区域号)01001250102(流水号)20100311(时间)001(序号),现在要改变这个值,
把流水号中的前两位‘01’去掉,变为‘001250102’, 在'序号'之前加上两个字符‘00’,变为
'00001',最后更新为
510100 001250102 20100311 00001
由于tcardid值很多,手改不行,想问问能不能用sql语句解决?谢谢各位了!
解决方案 »
- ASPxGridView中的一列,把它Change To,Combobox Column后,实现了下拉框的功能。但不能输入新的,也就是下拉列表里没有的值。问如何实现?
- 访问数据库
- 急,急,验证身份证为空时让其通过怎么办??
- 多个菜单项 共用一个OnClick处理程序
- 100分求Jmail 4.3或 4.4 Pro文件,分不够还可以加!
- 求助,FINDWINDOWEX一些用法。
- 请问如何用DataGrid显示不同颜色的记录?
- 關於Datagridview問題
- 有个C# lock问题,大神帮忙解答一下
- C#和C.NET有什么不同
- C#产生指定范围内的随机数组问题—为什么产生的随机数会全部相同呢?
- 如何修改一个外部程序的ListView控件
update tb set tcadid=stuff(tcadid,7,2,'')
update tb set tcadid=stuff(tcadid,23,1,'000')
select @tcadid='5101000100125010220100311001'
select @tcadid
select @tcadid=stuff(@tcadid,7,2,'')
select @tcadid
select @tcadid=stuff(@tcadid,23,1,'000')
select @tcadid
----------------------------------------------------------------------------------------------------
5101000100125010220100311001(所影响的行数为 1 行)
----------------------------------------------------------------------------------------------------
51010000125010220100311001(所影响的行数为 1 行)
----------------------------------------------------------------------------------------------------
5101000012501022010031000001(所影响的行数为 1 行)
update tb set tcadid=stuff(tcadid,24,1,'000')
declare @tcadid nvarchar(100)
select @tcadid='5101000100125010220100311001'
select @tcadid
select @tcadid=stuff(@tcadid,7,2,'')
select @tcadid
select @tcadid=stuff(@tcadid,24,1,'000')
select @tcadid
----------------------------------------------------------------------------------------------------
5101000100125010220100311001(所影响的行数为 1 行)
----------------------------------------------------------------------------------------------------
51010000125010220100311001(所影响的行数为 1 行)
----------------------------------------------------------------------------------------------------
5101000012501022010031100001(所影响的行数为 1 行)
Set tcardid = stuff(stuff(tcadid,7,2,''),23,1,'000')
update tb set tcadid=stuff(tcadid,24,1,'000')
如SELECT STUFF('abcdef', 2, 3, '123456')
a123456ef