SQL2005触发器和存储过程
实现效果:在表中插入数据时,响应触发器在另外一个表插入数据
SQL命令
insert into myReport(Id,myName,myNum)values('40','小麦','20')
SQL触发器
create trigger [InsertDataNow]
on [dbo].[myReport]
for insert
as
begin
declare @myID as int
select @myID = ID from inserted
insert into bb(aa)values(@myID)
end
实现效果:创建存储过程
create procedure myReportInsert
@Id int,
@myName varchar(50),
@myNum int
as
insert into myReport(Id,myName,myNum)values(@Id,@myName,@myNum)
go
执行存储过程
exec myReportInsert '45','桔子',50