日期:2014-05-17 浏览次数:20368 次
create table #(id int ,name varchar(30),add1 varchar(30))
insert into #
select 3 , '我爱我家(1234567)' , 'xxx22' union all
select 4 , '您好(4567543)' , 'ereww' union all
select 5 , '广州市(987678)' , 'eeee'
select *,substring(name,charindex('(',name)+1,charindex(')',name)-charindex('(',name)-1)number from #
/*
id name add1 number
----------- ------------------------------ ------------------------------ ------------------------------
3 我爱我家(1234567) xxx22 1234567
4 您好(4567543) ereww 4567543
5 广州市(987678) eeee 987678
(3 row(s) affected)
*/
select substring(name,charindex('(',name)+1,charindex(')',name)-charindex('(',name)-1) as 数字 from 表A