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 |
|
sunil
Constraint Violating Yak Guru
282 Posts |
Posted - 2005-12-29 : 04:17:53
|
| Can we have a table that has primary key and foreign key with in itself.example-:We have a table employees and 2 fields EmpID and ManagerID.Here , EmpId is Primary Key and ManagerID is foreign Key.Can this be possible? If yes, How is Referential Integrity maintained here. |
|
|
shallu1_gupta
Constraint Violating Yak Guru
394 Posts |
Posted - 2005-12-29 : 04:42:13
|
| yes it is possible.ManagerId can either be null or can be the empId which exists in the table. ALTER TABLE <tableName> ADD CONSTRAINT <ConstraintName> FOREIGN KEY ( ManagerId) REFERENCES <TableName>(EmpId) |
 |
|
|
|
|
|