一张表中,提起name中的数字,并显示 Id name add 3 我爱我家(1234567) xxx22 4 您好(4567543) ereww 5 广州市(987678) eeee
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
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; / 为什么老出现编译错误,我这还是从课本上抄的,哪位高手指导一下
Id name add
3 我爱我家(1234567) xxx22
4 您好(4567543) ereww
5 广州市(987678) eeee
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)
*/
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;
/
为什么老出现编译错误,我这还是从课本上抄的,哪位高手指导一下