Click here to Skip to main content
15,909,051 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
i have 3 tables :

1.Human
2.Club
3.HumanClub

that HumanClubs contains :
idHuman
idClub

How can i insert records into HumanClub table??
Posted
Updated 1-Mar-13 2:18am
v2
Comments
[no name] 1-Mar-13 9:00am    
Do you know SQL. What efforts have you put..

1 solution

Enjoy...


SQL
create table Human(id int IDENTITY,SomeField varchar(50))
create table Club(id int IDENTITY,SomeField varchar(50))
create table HumanClub(id int IDENTITY,HumanId int, ClubId INT)

DECLARE @HumarId INT, @ClubId INT
INSERT INTO Human values('Some Human')
SET @HumarId = SCOPE_IDENTITY()
INSERT INTO Club values('Some Club')
SET @ClubId = SCOPE_IDENTITY()
INSERT INTO HumanClub values(@HumarId,@HumarId)
SELECT * FROM HumanClub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900