Remove-PrimaryKey

Removes a primary key from a table.

Syntax

Remove-PrimaryKey [-TableName] <String> [-SchemaName <String>] [<CommonParameters>]
Remove-PrimaryKey [-TableName] <String> [-SchemaName <String>] [-Name] <String> [<CommonParameters>]

Description

The Remove-PrimaryKey operation removes a primary key from 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
Name String

The name of the primary key to remoe.

true false

EXAMPLE 1

Remove-PrimaryKey 'Cars' -Name 'Car_PK'

Demonstrates how to remove a primary key whose name is different than the derived name Rivet creates for primary keys.