分不多了,全部家当诚求一触发器,在线等
RoleTb 表
RoleId RoleName
---------------------
PerTb 表
PerId RoleId UiId
---------------------
我想在RoleTb 表插入一条数据 比如
insert into RoleTb values( 'yourname ', '注册用户 ')
---------------------
就在PerTb 表里插入四条数据
yourname,1
yourname,2
yourname,3
yourname,4
其中PerId是自动增长字段,
[解决办法]
create trigger test on RoleTb for insert
as
set nocount on
insert PerTb
select RoleID, 1 from inserted union all
select RoleID, 2 from inserted union all
select RoleID, 3 from inserted union all
select RoleID, 4 from inserted
set nocount off
go