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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 ALTER table need help please

Author  Topic 

jennypretty
Yak Posting Veteran

96 Posts

Posted - 2004-10-22 : 10:23:52
CREATE TABLE EMP(
EMP_ID VARCHAR(20),
EMP_DEPT NUMERIC
CONSTRAINT EMP_PK PRMARY KEY(EMP_ID),
CONTRAINT EMP_FK FOREIGN KEY(EMP_DEPT)
REFERENCES DEPT)
GO

NOW, How do I alter this table FK to point to SALARY table?
CONTRAINT EMP_FK FOREIGN KEY(EMP_DEPT)
REFERENCES SALARY)

THANKS.

JENNY

The stupid question is the question you don't ask.
www.single123.com

surefooted
Posting Yak Master

188 Posts

Posted - 2004-10-22 : 11:18:38
[code]
Alter Table EMP
DROP CONSTRAINT EMP_FK

Alter TAble EMP
ADD CONSTRAINT EMP_FK FOREIGN KEY(EMP_DEPT)
REFERENCES SALARY(EMP_DEPT)
[/code]

-Jon
Should still be a "Starting Member" .
Go to Top of Page

jennypretty
Yak Posting Veteran

96 Posts

Posted - 2004-10-22 : 11:45:46
Woh, it worked.
Thanks so much, surefooted.
Jenny.

The stupid question is the question you don't ask.
www.single123.com
Go to Top of Page

surefooted
Posting Yak Master

188 Posts

Posted - 2004-10-22 : 11:58:57
No problem.

-Jon
Should still be a "Starting Member" .
Go to Top of Page
   

- Advertisement -