• 全部
• 基础类
• 应用实例
• 新技术前沿

# ～～～～～～～～～字段截取的问题?　100分求～～～～～～～

wendi 2006-06-08 11:12:25

A | B C
813zx-01-5/9 |
813zx-01-5/12 |

...全文
113 点赞 收藏 6

6 条回复

wwh999 2006-06-08
update 表名稱 set b=Substring(A,charindex('/',A)-1,1),c=Substring(A,charindex('/',A)+1,len(A))

xeqtr1982 2006-06-08
declare @T table(A varchar(20),B varchar(20),C varchar(20))
insert into @t(A) select '813zx-01-5/9'
union all select '813zx-01-5/12'
union all select '813zx-01-51/12'
union all select '813zx-01-53331/31312'

update @t set b=left(right(A,charindex('-',reverse(A))-1),charindex('/',right(A,charindex('-',reverse(A))-1))-1),
c=Substring(right(A,charindex('-',reverse(A))-1),charindex('/',right(A,charindex('-',reverse(A))-1))+1,len(right(A,charindex('-',reverse(A))-1)))

select * from @t

lxzm1001 2006-06-08
update tablename set b=substring(A,10,1),c=right(a,len(a)-charindex('/',a))

lxzm1001 2006-06-08
update tablename set c=right(a,len(a)-charindex('/',a))

xeqtr1982 2006-06-08
declare @T table(A varchar(20),B varchar(20),C varchar(20))
insert into @t(A) select '813zx-01-5/9'
union all select '813zx-01-5/12'

update @t set b=Substring(A,charindex('/',A)-1,1),c=Substring(A,charindex('/',A)+1,len(A)) from @t
select * from @t

lxzm1001 2006-06-08
update tablename set b=substring(A,10,1)

MS-SQL Server

3.3w+

MS-SQL Server相关内容讨论专区

2006-06-08 11:12