Create Trigger test_tri5
on test
after insert
as
begin
declare @id sysname, @tel sysname, @name sysname
select @tel=ltrim(tel),@id=ltrim([id]),@name=ltrim([name]) from inserted;
insert into test2(id,tel,[name]) values(@id,@tel,@name);
end
这样,只要往test表插入一条记录,就回立马执行
insert into test2(id,tel,[name]) values(@id,@tel,@name);
往另外一张表中自动插入一条记录,并且获得了刚刚自动增加的id