PositiveGuy
PositiveGuy

Reputation: 47743

Cannot Specify Foreign Key Tables When Adding New Foreign Keys

I'm trying to use the Relationships dialog in SQL 2008 to add a new foreign key to a table field. When I go to add one, I am not able to change and specify the Foreign Key Base table or any others in the "Tables and Columns Specification" area...they're all greyed out for those values and uneditable and I"m not sure why.

Upvotes: 3

Views: 2668

Answers (3)

afluiter
afluiter

Reputation: 1

Easier is to add a database diagram, add the desired tables, then drag/drop the relations from and to the intended fields. In this way a logic name of the relation will also be created.

Upvotes: 0

Damir Sudarevic
Damir Sudarevic

Reputation: 22187

Well, this is too visual for me.

ALTER TABLE dbo.MyTable 
  ADD myNewColumn int NOT NULL
go

 ALTER TABLE dbo.MyTable
   ADD CONSTRAINT FK1_MyTable FOREIGN KEY(myNewColum) REFERENCES dbo.myRefTable(ID)
go

If you try this "the thing" may come-up with some kind of an error that describes where the problem is.

Upvotes: 1

gbn
gbn

Reputation: 432271

Have you clicked the ellipsis button to get the wee dialog box?

The section "Tables and Columns Specification" area has a wee button where you choose the tables and columns: you can't enter stuff directly.

Upvotes: 11

Related Questions