How to remove a SQL Server Constraint

Asked

Viewed 2,160 times

0

I’m having a problem removing a Constraint from a table.

Objective is to delete the Constraint to delete a table.

The problem is: I have an Income table that is associated with Extra Income. This Performance table is with FK_COD_RENDA_EXTRA.

ALTER TABLE RENDIMENTO_EXTRA DROP CONSTRAINT [COD_RENDA_EXTRA]

but returns the Error message

"Message 3728, Level 16, Status 1, Line 2 'COD_RENDA_EXTRA' is not a restriction. Message 3727, Level 16, Status 0, Line 2 Unable to cancel restriction. See previous errors."

inserir a descrição da imagem aqui

  • 1

    Probably the name of the Constraint is wrong, you are referring to FK and not the Constraint itself. In your print, below the column VAL_SALARIO_FIXO click on [+]Restrições there will be listed the constraints

  • 1

    Caique, really the Constraint was under the wrong name, the correct name was [FK_RENDIMEN_REFERENCE_RENDIMEN]. That’s why it wasn’t locating. Vlw

1 answer

2

From what I understand your Constraint is [FK_COD_RENDA_EXTRA] on the table Income. Change the name and table of the Constraint to perform the drop correctly, as this has to be done in the table containing the FK.

ALTER TABLE [Rendimento] DROP CONSTRAINT [FK_COD_RENDA_EXTRA]
  • Andyson, I got it here. VLW for the help

Browser other questions tagged

You are not signed in. Login or sign up in order to post.