日期:2014-05-17 浏览次数:20456 次
declare @string varchar(20)
set @string ='123aaabbb13482'
select stuff(@string,CHARINDEX ('aaabbb',@string),len(@string),'')
if object_id('[TB]') is not null drop table [TB]
go
create table [TB] (col nvarchar(34))
insert into [TB]
select '1aaabbbcccdd.1' union all
select '12aaabbbccccd.ada' union all
select '123aaabbbccc.8?' union all
select '1234aaabbbcc.1'
select * from [TB]
SELECT SUBSTRING(col,0,CHARINDEX('aaabbb',col)) FROM dbo.TB
/*
1
12
123
1234*/
update table
set name=left(name,charindex('aaabbb',name)-1)