I am new to SQL and struggling with some basic code!
How do I use the ALTER TABLE command to add a foreign key constraint?
I have the correct code for creating the tables and adding the constraints
when creating, but can't figure out how to modify an existing table and add
a FK.
ThanksHi,
Sample code:-
create table t90(i int primary key)
go
create table t91(i int)
go
alter table t91 add constraint fk_t1 foreign key(i) references t90(i)
Thanks
Hari
MCDBA
"Keith" <@..> wrote in message news:uQUuKStTEHA.4048@.TK2MSFTNGP12.phx.gbl...
> I am new to SQL and struggling with some basic code!
> How do I use the ALTER TABLE command to add a foreign key constraint?
> I have the correct code for creating the tables and adding the constraints
> when creating, but can't figure out how to modify an existing table and
add
> a FK.
> Thanks
>
No comments:
Post a Comment