Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create a FK in T-SQL 1

Status
Not open for further replies.

siituser

Programmer
Sep 30, 2002
67
0
0
CA
I need to create a FK relationship in T-SQL. I've only ever done these in Enterprise Manager.

The table already exists. I was trying to use:

ALTER TABLE emailsendlist
add CONSTRAINT FK_EmailSendList_ActivityType

but I think I need a few more parameters.

Thanks in advance!

Kevin
 
Sample from BOL

CREATE TABLE part_sample
(part_nmbr int PRIMARY KEY,
part_name char(30),
part_weight decimal(6,2),
part_color char(15) )


CREATE TABLE order_part
(order_nmbr int,
part_nmbr int
FOREIGN KEY REFERENCES part_sample(part_nmbr)
ON DELETE NO ACTION,
qty_ordered int)
GO


Denis The SQL Menace
SQL blog:
Personal Blog:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top