July 7, 2008 at 1:53 pm
I'm trying to run a script that will put two keys onto a db. So far no problem. But when I go to look at the keys, the name of the fk is ALL Weird. Numbers, Letters, Underscores....
Is there a way to name the key so when I look at it, it makes sense?
ALTER TABLE table1
ADD FOREIGN KEY (UserID) REFERENCES User(userID);
the name of they key should be something like FKTable1_User, but it's messed up. any way to add in a param to name the key in the alter stmt?
July 7, 2008 at 1:56 pm
You have to manually supply the name, instead of letting SQL Server pick one.
You can look up the format of the alter table statement in SQL Server Books Online.
July 7, 2008 at 1:58 pm
Matthew Cushing (7/7/2008)
I'm trying to run a script that will put two keys onto a db. So far no problem. But when I go to look at the keys, the name of the fk is ALL Weird. Numbers, Letters, Underscores....Is there a way to name the key so when I look at it, it makes sense?
ALTER TABLE table1
ADD FOREIGN KEY (UserID) REFERENCES User(userID);
the name of they key should be something like FKTable1_User, but it's messed up. any way to add in a param to name the key in the alter stmt?
ALTER TABLE table1
ADD CONSTRAINT FKTable1_User FOREIGN KEY (UserID) REFERENCES User(userID);
* Noel
July 7, 2008 at 2:09 pm
awesome, thanks.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply