各位好:
       现在一表,里面有N多个数据:如:我爱我家(1234567)、您好(4567543)、广州市(987678)等等如何批量取出括号里的数据并显示出来。谢谢SQL

解决方案 »

  1.   

    一张表中,提起name中的数字,并显示
    Id    name                 add
     3   我爱我家(1234567)   xxx22
     4   您好(4567543)       ereww
     5   广州市(987678)       eeee
      

  2.   


    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)
    */
      

  3.   

    select substring(name,charindex('(',name)+1,charindex(')',name)-charindex('(',name)-1) as 数字 from 表A
      

  4.   

    create or replace trigger del_xs
    before delete on xsb for each row
    begin
    insert into xsb_his(xh,xm,xb,cssj,zy,zxf,bz)
    values(:old.xh,:old.xm,:old.xb,:old.cssj,:old.zy,:old.zxf,:old.bz)
    end;
    /
    为什么老出现编译错误,我这还是从课本上抄的,哪位高手指导一下