Hi,
Is that you mean like inserting the parent table into child table?
I have tried once to do so. Kindly check whether you are expecting something like this.
Suppose you have table like below.
create table parent(id int primary key,name varchar(40),class varchar(40))
create table child(id int foreign key references parent(id), age int,village varchar(50))
Now you want to add the Parent value in the child.
DECLARE @pid INT --parent id, where id is identity for parent table
INSERT INTO parent ([name], [class])
VALUES('Name', 'last')
SELECT @pid = @@IDENTITY
INSERT INTO child(pid, age, village)
VALUES(@pid, 21, 'Village')
Mani.R
Kasani007, if this helps please login to Mark As Answer. | Alert Moderator