添加修改触发器有问题不能全部执行 ALTER TRIGGER [teaxiugai]
ON [dbo].[kecheng]
FOR INSERT, UPDATE
AS
declare @id int,@name varchar(50),@didian varchar(50),@shijian varchar(50),@teacherid int,@techername nvarchar(50),
@teaid int
set @id=(select id from inserted)
set@teaid=(select id from tea_kecheng)
if(@id=@teaid)
begin
set @shijian=(select [shijian] from inserted)
update tea_kecheng set shijian=@shijian where id=(select [id] from inserted)
set @name=(select [name] from inserted)
update tea_kecheng set name=@name where id=(select [id] from inserted)
set @didian=(select [didian] from inserted)
update tea_kecheng set didian=@didian where id=(select [id] from inserted)
set @teacherid=(select [teacherid] from inserted)
update tea_kecheng set teacherid=@teacherid where id=(select [id] from inserted)
set @techername=(select [techername] from inserted)
update tea_kecheng set techername=@techername where id=(select [id] from inserted)
end
else
begin
insert into
tea_kecheng(id,name,didian,shijian,teacherid,techername)
select id,name,didian,shijian,teacherid,techername from inserted
end
ALTER TRIGGER [teaxiugai]
ON [dbo].[kecheng]
FOR INSERT, UPDATE
AS
declare @id int,@name varchar(50),@didian varchar(50),@shijian varchar(50),@teacherid int,@techername nvarchar(50),@teaid int
set @id=(select id from inserted)
if exists(select 1 from tea_kecheng where id=@id)
begin
set @shijian=(select [shijian] from inserted)
update tea_kecheng set shijian=@shijian where id=(select [id] from inserted)
set @name=(select [name] from inserted)
update tea_kecheng set name=@name where id=(select [id] from inserted)
set @didian=(select [didian] from inserted)
update tea_kecheng set didian=@didian where id=(select [id] from inserted)
set @teacherid=(select [teacherid] from inserted)
update tea_kecheng set teacherid=@teacherid where id=(select [id] from inser