# Trigger: dEmployee

## Properties

Property | Value
--- | ---
Trigger | dEmployee
ID | 1579152671
Owner | dbo
Schema | HumanResources
For Object | Employee
Disabled |
Is Not For Replication |
Trigger Type Description | SQL TRIGGER
ANSI NULLS |
QUOTED IDENTIFIER |
Encrypted |
MS Shipped |
Execute As | Caller
Modify Date | 8/8/2010 5:23:44 PM
Creation Date | 8/8/2010 5:23:44 PM

## Extended Properties

Name | Value
--- | ---
MS_Description | INSTEAD OF DELETE trigger which keeps Employees from being deleted.

## Trigger Type

Is After Trigger | Is Instead Of | Insert Trigger | Update Trigger | Delete Trigger
--- | --- | --- | --- | ---

## First / Last Trigger

First Delete Trigger | First Insert Trigger | First Update Trigger | Last Delete Trigger | Last Insert Trigger | Last Update Trigger
--- | --- | --- | --- | --- | ---

## Objects that depend on [dEmployee]

- dEmployee

## Objects on which [dEmployee] depends

- dEmployee
  - HumanResources.Employee
    - Person.Person
      - Person.AdditionalContactInfoSchemaCollection
      - Person.BusinessEntity
      - Demographics.exist
      - Person.IndividualSurveySchemaCollection
      - dbo.Name
      - dbo.NameStyle
    - dbo.Flag

## SQL

Script
SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON CREATE TRIGGER [HumanResources].[dEmployee] ON [HumanResources].[Employee] INSTEAD OF DELETE NOT FOR REPLICATION AS BEGIN DECLARE @Count int; SET @Count = @@ROWCOUNT; IF @Count = 0 RETURN; SET NOCOUNT ON; BEGIN RAISERROR (N'Employees cannot be deleted. They can only be marked as not current.', -- Message 10, -- Severity. 1); -- State. IF @@TRANCOUNT > 0 BEGIN ROLLBACK TRANSACTION; END END; END; EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'INSTEAD OF DELETE trigger which keeps Employees from being deleted.' , @level0type=N'SCHEMA',@level0name=N'HumanResources', @level1type=N'TABLE',@level1name=N'Employee', @level2type=N'TRIGGER',@level2name=N'dEmployee'

#### See also

List of Triggers