This is a discussion on Foreign key relationship within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi Im a sql newbie , and have created two tables with a foreign key relationship. How do i ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi Im a sql newbie , and have created two tables with a foreign key relationship. How do i insert into these tables. If i insert into the primary table will the foreign key field in the second table be automaticly updated by ms sql server ? |
| ||||
| Hi If you are inserting data into the referenced table ("primary"!) then by definition there will be no entries in the referencing table ("foreign key"!). If you are entering data in the referencing table then there must be a corresponding entry in the referenced table. If you update the referenced fields in the referenced table, you will need to specify UPDATE CASCADE on the foreign key definition to propagate the changes. (See CREATE TABLE in Books online). John <timmy_dale12@hotmail.com> wrote in message news:5bd31089.0308080131.14868339@posting.google.c om... > Hi > Im a sql newbie , and have created two tables with a foreign key > relationship. > > How do i insert into these tables. If i insert into the primary table > will the foreign key field in the second table be automaticly updated > by ms sql server ? |