Drop foreign Key constraint

  • Hi Everyone,

    I come accross a strange situation in database that I was not able to drop a foreign key constraint using the T-SQL script (even with GUI, it couldn't be dropped). there are no locks or blocking is going on these tables.

    USE

    [ARData]

    GO

    ALTER TABLE [dbo].[Table Name] DROP CONSTRAINT [FK_Constraint]

    the constraint has ON UPDATE CASCADE clause. I am not sure this would do something different to drop a foreign key constraint other than the above T-SQL statement. Anyhelp is greatly apprecaited.

     

  • You cannot drop a foriegn key with DRI(declarative referential integrity) constrant because the CASCADE UPDATE, CASCADE DELETE, CASCADE SET NULL and CASCADE SET DEFAULT if all are enabled must be dropped before you can drop the foriegn key. 

    DRI means if A references B B must exist you are trying to drop B which will lead to data integrity issues and the Relational model is set up to stop such operations.

     Hope this helps.

     

    Kind regards,
    Gift Peddie

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply