Thursday, March 8, 2012

Add relation to new table

If i add a new table to my database with a stored procedure, using that same sp or another can i also add a 1-M relationship with another table that is currently in the database. Please if you can provide an example.

Thank you,You need to add a foreign key constraint to the child table. Here's an example from SQL Server Books Online, which creates a job_id field that is a FK to the jobs table:

job_id smallint NOT NULL
DEFAULT 1
REFERENCES jobs(job_id)

That enough information? You can also modify an existing table.

Don

No comments:

Post a Comment