Unable to Create Trigger - The object does not exist or is invalid

  • Title about says it all

    The error specifically is -

    Msg 8197, Level 16, State 4, Procedure dbo.trg_manageTrailerInventoryHistory, Line 2

    The object 'dbo.TrailerInventory' does not exist or is invalid for this operation.

    USE [TrailerManagement]

    GO

    /****** Object: Table [dbo].[TrailerInventory] Script Date: 02/21/2010 21:54:30 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    CREATE TABLE [dbo].[TrailerInventory](

    [DOTNumber] [nvarchar](12) NOT NULL,

    [OwnerId] [int] NOT NULL,

    [Type] [int] NULL,

    [IsInFleet] [bit] NOT NULL,

    [BaseFleetNumber] [nvarchar](6) NULL,

    [CurrentInventoryHistoryRecordId] [int] NULL,

    CONSTRAINT [PK_TrailerInventory] PRIMARY KEY CLUSTERED

    (

    [DOTNumber] ASC

    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

    ) ON [PRIMARY]

    GO

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    CREATE TRIGGER [dbo.trg_manageTrailerInventoryHistory] ON [dbo.TrailerInventory]

    AFTER INSERT, UPDATE

    AS

    BEGIN

    -- SET NOCOUNT ON added to prevent extra result sets from

    -- interfering with SELECT statements.

    SET NOCOUNT ON;

    execute sp_manageTrailerInventoryHistoryRecord '12027'

    END

    GO

  • You just have you brackets a little bit off:

    CREATE TRIGGER [dbo].[trg_manageTrailerInventoryHistory] ON [dbo].[TrailerInventory]

    AFTER INSERT, UPDATE

    AS

    BEGIN

    -- SET NOCOUNT ON added to prevent extra result sets from

    -- interfering with SELECT statements.

    SET NOCOUNT ON;

    execute sp_manageTrailerInventoryHistoryRecord '12027'

    END

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • I fixed the brackets, but its still a no-go. I even copied the altered code as-is.

  • ...and then I switched databases from 'master' to the correct database. Imagine how that fixes things.

  • Heh, we've all been there. Glad we could help.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • ...like misspelling a column name only to discover the mistake too deep into development to change it?

  • see if it is a view.

    only instead of trigger can be created on view.:cool:

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply