AFTER INSERT trigger not firing in SQL 2005

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ibrettferguson@gmail.com

    AFTER INSERT trigger not firing in SQL 2005

    Nothing fancy; just a trigger on a sharepoint table that supposed to
    write a record to another SQL table.


    set ANSI_NULLS ON
    set QUOTED_IDENTIFI ER ON
    go

    ALTER TRIGGER [TV_UpdateFileSy ncProgress]
    ON [dbo].[Docs]
    AFTER INSERT
    AS
    BEGIN
    SET NOCOUNT ON;

    BEGIN
    IF EXISTS (SELECT null FROM inserted WHERE DirName like
    'csm/%/Shared Documents')

    BEGIN
    IF NOT EXISTS (SELECT null FROM inserted INNER JOIN
    TV_FileSyncProg ress fp ON LOWER(RTRIM(fp. LeafName)) =
    LOWER(RTRIM(Rep lace(Replace(in serted.DirName, 'csm/',''),'/Shared
    Documents','') + '\' + inserted.LeafNa me)))

    BEGIN
    INSERT INTO TV_FileSyncProg ress (InternalOrigin , ExternalOrigin,
    ChangeType, SiteId, DirName, LeafName, FlagForDelete)
    SELECT
    0,1,1,SiteId,'F :\common\Extran et\',Replace(Re place(DirName,' csm/',''),'/Shared
    Documents','') + '\' + LeafName,0 FROM inserted

    END

    END

    END

    END

  • ibrettferguson@gmail.com

    #2
    Re: AFTER INSERT trigger not firing in SQL 2005


    ibrettferguson@ gmail.com wrote:
    Nothing fancy; just a trigger on a sharepoint table that supposed to
    write a record to another SQL table.
    >
    >
    set ANSI_NULLS ON
    set QUOTED_IDENTIFI ER ON
    go
    >
    ALTER TRIGGER [TV_UpdateFileSy ncProgress]
    ON [dbo].[Docs]
    AFTER INSERT
    AS
    BEGIN
    SET NOCOUNT ON;
    >
    BEGIN
    IF EXISTS (SELECT null FROM inserted WHERE DirName like
    'csm/%/Shared Documents')
    >
    BEGIN
    IF NOT EXISTS (SELECT null FROM inserted INNER JOIN
    TV_FileSyncProg ress fp ON LOWER(RTRIM(fp. LeafName)) =
    LOWER(RTRIM(Rep lace(Replace(in serted.DirName, 'csm/',''),'/Shared
    Documents','') + '\' + inserted.LeafNa me)))
    >
    BEGIN
    INSERT INTO TV_FileSyncProg ress (InternalOrigin , ExternalOrigin,
    ChangeType, SiteId, DirName, LeafName, FlagForDelete)
    SELECT
    0,1,1,SiteId,'F :\common\Extran et\',Replace(Re place(DirName,' csm/',''),'/Shared
    Documents','') + '\' + LeafName,0 FROM inserted
    >
    END
    >
    END
    >
    END
    >
    END

    Figured it out.

    A bug in my win service was deleting the records as they were being
    inserted in the destination table.

    Neat.

    (Today, I would like to own a lawn care business... yes, a lawn care
    business. )

    Comment

    Working...