Remove-ForeignKey

Removes a foreign key from an existing table that has a foreign key.

Syntax

Remove-ForeignKey [-TableName] <String> [-SchemaName <String>] [-References] <String> [-ReferencesSchema <String>] [<CommonParameters>]
Remove-ForeignKey [-TableName] <String> [-SchemaName <String>] -Name <String> [<CommonParameters>]

Description

Removes a foreign key to a table.

Parameters

Name Type Description Required? Pipeline Input Default Value
TableName String

The name of the table.

true false
SchemaName String

The schema name of the table. Defaults to dbo.

false false dbo
References String

OBSOLETE. Use the Name parameter to specify the foreign key to remove.

true false
ReferencesSchema String

OBSOLETE. Use the Name parameter to specify the foreign key to remove.

false false dbo
Name String

The name of the foreign key to remove.

true false

EXAMPLE 1

Remove-ForeignKey 'Cars' -Name 'FK_Cars_Year'

Demonstrates how to remove a foreign key that has a name different than Rivet's derived name.