# Trigger: uPurchaseOrderHeader

## Properties

Property | Value
--- | ---
Trigger | uPurchaseOrderHeader
ID | 1659152956
Owner | dbo
Schema | Purchasing
For Object | PurchaseOrderHeader
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 | AFTER UPDATE trigger that updates the RevisionNumber and ModifiedDate columns in the PurchaseOrderHeader table.

## 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 [uPurchaseOrderHeader]

- uPurchaseOrderHeader

## Objects on which [uPurchaseOrderHeader] depends

- uPurchaseOrderHeader
  - Purchasing.PurchaseOrderHeader
    - HumanResources.Employee
      - Person.Person
        - Person.AdditionalContactInfoSchemaCollection
        - Person.BusinessEntity
        - Demographics.exist
        - Person.IndividualSurveySchemaCollection
        - dbo.Name
        - dbo.NameStyle
      - dbo.Flag
    - Purchasing.Vendor
      - dbo.uspLogError
        - dbo.ErrorLog
        - dbo.uspPrintError
      - dbo.AccountNumber
    - Purchasing.ShipMethod

## SQL

Script
SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON CREATE TRIGGER [Purchasing].[uPurchaseOrderHeader] ON [Purchasing].[PurchaseOrderHeader] AFTER UPDATE AS BEGIN DECLARE @Count int; SET @Count = @@ROWCOUNT; IF @Count = 0 RETURN; SET NOCOUNT ON; BEGIN TRY IF NOT UPDATE([Status]) BEGIN UPDATE [Purchasing].[PurchaseOrderHeader] SET [Purchasing].[PurchaseOrderHeader].[RevisionNumber] = [Purchasing].[PurchaseOrderHeader].[RevisionNumber] + 1 WHERE [Purchasing].[PurchaseOrderHeader].[PurchaseOrderID] IN (SELECT inserted.[PurchaseOrderID] FROM inserted); END; END TRY BEGIN CATCH EXECUTE [dbo].[uspPrintError]; IF @@TRANCOUNT > 0 BEGIN ROLLBACK TRANSACTION; END EXECUTE [dbo].[uspLogError]; END CATCH; END; EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'AFTER UPDATE trigger that updates the RevisionNumber and ModifiedDate columns in the PurchaseOrderHeader table.' , @level0type=N'SCHEMA',@level0name=N'Purchasing', @level1type=N'TABLE',@level1name=N'PurchaseOrderHeader', @level2type=N'TRIGGER',@level2name=N'uPurchaseOrderHeader'

#### See also

List of Triggers