I have db in SQL Server 2008 R2.
I have table Users and some child tables that have foreign key relationships to UserID.
I forgot to add on cascade delete and update in the creation.
There is a way to do it now, without losing the data?
Thanks !
I have db in SQL Server 2008 R2.
I have table Users and some child tables that have foreign key relationships to UserID.
I forgot to add on cascade delete and update in the creation.
There is a way to do it now, without losing the data?
Thanks !
You have to drop the key and re-add it like this:
ALTER TABLE someTable DROP FOREIGN KEY someID;
ALTER TABLE someTable ADD FOREIGN KEY (someID) REFERENCES someOtherTable (ID) ON DELETE CASCADE;
I hope this helps.