sql 触发器学习笔记
create trigger [InsertData]
on Table_1
for insert
as
begin
declare @myID as int
select @myID = SectionID from inserted
insert into Copyfrom(sname,sstate,ssort)values(@myID,1,1)
end
上面是一触发器,创建在Copyfrom表中,在向Table_1中插入数据时,自动的向Copyfrom中插入数据
例如:执行下列语句:insert into Table_1(SectionID,CreatedTime,TextValue)values(\’40\’,\’小麦\’,\’20\’)
在Table_1中插入了一条语句,同时会在Copyfrom表中也会插入一条语句