Startup Stored Proc - INSERT fails, TRUNCATE works

  • USE master

    GO

    CREATE TABLE dbo.tblLastErrors (

            ErrorEntry varchar(255),

            ErrorEntryID int

    )

    GO

    CREATE PROCEDURE dbo.usp_Startup_ScanLastErrorlog

    AS

    SET NOCOUNT ON

    TRUNCATE TABLE master.dbo.tblLastErrors

    INSERT master.dbo.tblLastErrors EXEC master.dbo.xp_readerrorlog 1

    GO

    exec sp_procoption 'usp_Startup_ScanLastErrorlog', 'startup', 'true'

    GO

    Running this script and restarting should populate tblLastErrors with teh contents of the last SQL errorlog

    This is a cut-down script from what I'm attempting.

    The truncate works, not the INSERT.

    Any ideas

    Ta

    Shawn

  • xp_readerrorlog is one of function of xpstar.dll which run after the startup procedure.

  • I saw xpstar being loaded in the event log, but how does this affect the INSERT? Run it twice in the sp? Use WAITFOR?

  • Yes. It looks like.

Viewing 4 posts - 1 through 3 (of 3 total)

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