Add-Trigger

Creates a new trigger.

Syntax

Add-Trigger [-Name] <String> [-SchemaName <String>] [-Definition] <String> [<CommonParameters>]

Description

Creates a new trigger. If updating an existing trigger, use Remove-Trigger to remove it first, then New-Trigger to re-create it.

Related Commands

Parameters

Name Type Description Required? Pipeline Input Default Value
Name String

The name of the trigger.

true false
SchemaName String

The schema of the trigger.

false false dbo
Definition String

The body of the trigger. Everything after and including the ON clause.

true false

EXAMPLE 1

Add-Trigger 'PrintMessage' 'ON rivet.Migrations for insert as print ''Migration applied!'''

Creates a trigger that prints a method when a row gets inserted into the rivet.Migrations table.