22,209
社区成员
发帖
与我相关
我的任务
分享
create table tb(str1 varchar(50), str2 varchar(20))
insert into tb values('Central venous pressure (CVP)' , '')
go
update tb
set str2 = substring(str1 , charindex('(',str1) + 1 , charindex(')',str1) - charindex('(',str1) - 1)
where charindex('(',str1) > 0 and charindex(')',str1) > 0
select * from tb
drop table tb
/*
str1 str2
-------------------------------------------------- --------------------
Central venous pressure (CVP) CVP
(所影响的行数为 1 行)
*/
declare @s varchar(50)
set @s='Central venous pressure (CVP)'
select substring(@s,charindex('(',@s)+1,charindex(')',@s)-charindex('(',@s)-1)