Skip to content

Latest commit

 

History

History
64 lines (46 loc) · 2.49 KB

File metadata and controls

64 lines (46 loc) · 2.49 KB
title Delete foreign key relationships
description Learn more about how to delete foreign key from tables in the SQL Server Database Engine.
author WilliamDAssafMSFT
ms.author wiassaf
ms.date 08/28/2023
ms.service sql
ms.subservice table-view-index
ms.topic how-to
ms.custom
ignite-2025
helpviewer_keywords
foreign keys [SQL Server], deleting
removing foreign keys
deleting foreign keys
monikerRange =azuresqldb-current || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric-sqldb

Delete foreign key relationships

[!INCLUDE sqlserver2016-asdb-asdbmi-fabricsqldb]

You can delete a foreign key constraint in [!INCLUDE ssnoversion] by using [!INCLUDE ssManStudioFull] or [!INCLUDE tsql]. Deleting a foreign key constraint removes the requirement to enforce referential integrity.

Foreign keys reference keys in other tables, for more information, see Primary and Foreign Key Constraints.

Permissions

Requires ALTER permission on the table.

Use SQL Server Management Studio

To delete a foreign key constraint

  1. In Object Explorer, expand the table with the constraint and then expand Keys.

  2. Right-click the constraint and then select Delete.

  3. In the Delete Object dialog box, select OK.

Use Transact-SQL

To delete a foreign key constraint

  1. In Object Explorer, connect to an instance of [!INCLUDE ssDE].

  2. On the Standard bar, select New Query.

  3. Copy and paste the following example into the query window and select Execute.

    USE AdventureWorks2022;
    GO
    ALTER TABLE dbo.DocExe
    DROP CONSTRAINT FK_Column_B;
    GO

For more information, see ALTER TABLE (Transact-SQL).

Next steps