Declare @A Table (B Nvarchar(1000)) Insert @A Select N'动静(Dong Jin)' Union All Select N'AA(AA)'Update @A Set B=Stuff(B,CharIndex('(',B),CharIndex(')',B)-CharIndex('(',B)+1,'') Select * From @A --Result /* B 动静 AA */
declare @t table(B varchar(20)) insert @t select '动静(Dong Jin)' union all select 'AAA'update @t set B=replace(B,'(Dong Jin)','')select * from @t
我理解错误,应该用paoluo(一天到晚游泳的鱼) 的~
declare @s varchar(8000) , @n int , @n1 int set @s = '动静(Dong Jin)' set @n = charindex('(' , @s , 1) set @n1 = charindex(')' , @s , 1 ) set @s = stuff(@s , @n , @n1 - @n +1 ,'' ) print @S
Insert @A Select N'动静(Dong Jin)'
Union All Select N'AA(AA)'Update @A Set B=Stuff(B,CharIndex('(',B),CharIndex(')',B)-CharIndex('(',B)+1,'')
Select * From @A
--Result
/*
B
动静
AA
*/
insert @t select '动静(Dong Jin)' union all select 'AAA'update @t set B=replace(B,'(Dong Jin)','')select * from @t
set @s = '动静(Dong Jin)'
set @n = charindex('(' , @s , 1)
set @n1 = charindex(')' , @s , 1 )
set @s = stuff(@s , @n , @n1 - @n +1 ,'' )
print @S
update a set b='动静'
--------------------
把問題也想的太簡單了吧