Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Zath
Constraint Violating Yak Guru
298 Posts |
Posted - 2006-12-21 : 14:59:00
|
Trying to find how to change a constraint on a field in one of my tables.I changed some things around and forgot this contraint... locationId int NOT NULL DEFAULT 16, CONSTRAINT FK_locationId_tblEquipmentSchedule FOREIGN KEY (locationId) REFERENCES tblLocation (locationID), The reference tblLocation should now be tblRackLocation.How can I change this?Thanks,Zath |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-12-21 : 15:10:34
|
You can't change a constraint. You must drop, then create.ALTER TABLE...Tara Kizer |
 |
|
Zath
Constraint Violating Yak Guru
298 Posts |
Posted - 2006-12-21 : 15:45:02
|
Didn't know that, so luckily it's still in development and was able to drop the table and recreate. Didn't have to deal with importing or exporting the data.Thanks,Zath |
 |
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2006-12-22 : 04:42:48
|
"Didn't know that, so luckily it's still in development and was able to drop the table and recreate. Didn't have to deal with importing or exporting the data."I don't think it was necessary to go this far....Tara was advising dropping the constraint and re-creating the constraint only. |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-12-22 : 11:01:07
|
Yes that's correct. Zath, please check SQL Server Books Online for ALTER TABLE. You will see ALTER TABLE DROP CONSTRAINT and ADD CONSTRAINT in there.Tara Kizer |
 |
|
|
|
|