arrow_backwardBack to SQL Server code examples

SQL Server How to remove a foreign key (or constraint) from an existing table

Removing a foreign key (otherwise known as a relation or association) from a SQL Server table. Note that after removing a relation, you might also want to remove any left over indexes.
ALTER TABLE
  [dbo].[users] DROP CONSTRAINT [department_id_fk_constraint]

Using Beekeeper Studio?

Beekeeper Studio is a free and open source database manager for Windows, Mac, and Linux.

This feature is baked right in, so there's no need to manually type SQL every time. Access foreign key editing by right-clicking on a table in the sidebar and clicking 'View Structure', then click 'Relations'.

Download Beekeeper Studio