在级联表中插入新记录

时间:2015-03-26 12:28:24

标签: sql tsql

enter image description here

目标:要在3个级联表中插入新数据所有者身份ID,RollID,PeopleID都是自动增量(播种ID)..

RollNumber             FullName

444201000703904        HALL SANDRA THELMA    
444201000703905        GOLDING RONALD JESSE  
444201000703908        CLAYTON JOHN WESLEY  
444201001704556        MARS LTD         
444201001704558        ONTARIO LTD          
444201001704560        DECARLE DAVE     

在这里帮助我如何创建SQL脚本但是第一个定时器......

1 个答案:

答案 0 :(得分:0)

declare @roll_id int, @people_id  
insert into people (fullname) values ('HALL SANDRA THELMA');
set @people_id select SCOPE_IDENTITY();
insert into roll (rollnumber) values ('444201000703904');
set @roll_id select SCOPE_IDENTITY(); 
insert into ownership (roll_id, people_id) values (@roll_id, @people_id);