Groups | Blog | Home
all groups > sql server programming > may 2006 >

sql server programming : Renaming Foreign Key



Anchi
5/3/2006 9:40:59 PM
Hi,

Does anyone know if there's a way of renaming a foreign key?
Or even name the foreign key on key creation?

Thanks
Anchi
5/3/2006 9:49:49 PM
Don't worry, think I've just worked it out.

Thanks anyway
Anchi
5/3/2006 10:02:35 PM
Thanks Uri.

Yes for those interested I dropped the table and recreated it using:

CREATE TABLE TEST (
COL1 TEXT,
COL2 INT CONSTRAINT FK_TEST_A FOREIGN KEY REFERENCES Table_A,
COL3 VARCHAR(50)
)

Of course dropping the foreign key is sufficient but I was after a way
of defining the foreign key name during table creation.

Thanks
Uri Dimant
5/4/2006 7:50:16 AM
Hi
You will have to drop a FOREIGN KEY CONSTRAINT and then create a new one


[quoted text, click to view]

Tibor Karaszi
5/4/2006 11:38:31 AM
.... or use sp_rename.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/


[quoted text, click to view]
AddThis Social Bookmark Button