Click here to Skip to main content
15,616,232 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have this query
create table reservation(
customer_id int not null references customer(customer_id),
trip_id int not null references trip(trip_id),
seat_nb int not null
primary key(customer_id,trip_id))

where customer is a table that has customer_id as a primary key of it's own as same as trip table
now I want to make both foreign keys to stand for a primary key in reservation table
but the sql server gives this error message
"the insert statement conflict with foreign key constraint"
Updated 28-Apr-10 3:16am

1 solution

Try the following instead
create table reservation(
  customer_id int not null references customer(customer_id)
 ,trip_id int not null references trip(trip_id)
 ,seat_nb int not null

alter table reservation add primary key(customer_id,trip_id)

I had this work on Oracle. Should be same on SQLServer. :)
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