CREATE TABLE dbo. Elmah_error (ErrorID uniqueidentifier not NULL, application NVARCHAR ( -) COLLATE sql_latin1_general_cp1_ci_as not NULL, Host NVARCHAR ( -) COLLATE sql_latin1_general_cp1_ci_as not NULL, Type NVARCHAR ( -) COLLATE sql_latin1_general_cp1_ci_as not NULL, Source NVARCHAR ( -) COLLATE sql_latin1_general_cp1_ci_as not NULL, Message NVARCHAR ( -) COLLATE sql_latin1_general_cp1_ci_as not NULL, [User] NVARCHAR ( -) COLLATE sql_latin1_general_cp1_ci_as NOT NULL, StatusCode int. NOT NULL, TIMEUTC DATETIME NOT NULL, SEQ Uence INT IDENTITY (1,1) NOT NULL, Allxml NTEXT COLLATE sql_latin1_general_cp1_ci_as no null) on [PRIMARY] textimage_on [Primary]go ALTER TABLE dbo. Elmah_error with NOCHECK ADD CONSTRAINT pk_elmah_error PRIMARY KEY nonclustered (ErrorID) on [PRIMARY] Goalter TABLE dbo. Elmah_error ADD CONSTRAINT Df_elmah_error_errorid DEFAULT (NEWID ()) for [errorid]gocreate nonclustered INDEX Ix_elmah_ ERROR_APP_TIME_SEQ on dbo. Elmah_error ([application] ASC, [TIMEUTC] desc, [Sequence] desc) on [Primary]goset quoted_identifier on Goset ANS I_nulls on Gocreate PROCEDURE dbo. Elmah_geterrorxml (@Application NVARCHAR ( -), @ErrorId uniqueidentifier) ASSET NOCOUNT ONSELECT allxmlfrom elmah_errorwhere errorid=@ErrorIdAND Application=@ApplicationGOSET quoted_identifier OFF goset ANSI_NULLS on Goset quoted_identifier on Goset ansi_nulls on Gocreate P Rocedure dbo. Elmah_geterrorsxml (@Application NVARCHAR ( -), @PageIndex INT=0, @PageSize INT= the, @TotalCount INT OUTPUT) As SET NOCOUNT ondeclare @FirstTimeUTC datetimedeclare @FirstSequenceintDECLARE @StartRowintDECLARE @StartRowIndexint--Get The ID of the first error forThe requested Pageset @StartRowIndex= @PageIndex * @PageSize +1SET ROWCOUNT @StartRowIndexSELECT @FirstTimeUTC=TIMEUTC, @FirstSequence=sequencefrom elmah_errorwhere Application=@ApplicationORDER by timeutc desc, Sequence desc--NowSetThe row count to the requested page size andGet--All records below it forThe pertaining application. SET ROWCOUNT @PageSizeSELECT @TotalCount= COUNT (1) from Elmah_errorwhere application=@ApplicationSELECT ErrorID, Application, host, type, source, message, [user], StatusCode, CONVERT (VARCHAR ( -), TIMEUTC,126) +'Z'timefrom elmah_error errorwhere application=@ApplicationAND TIMEUTC<=@FirstTimeUTCAND Sequence<=@FirstSequenceORDER by Timeutc DESC, Sequence descfor XML autogoset quoted_identifier OFF goset ANSI_NULLS On Goset quoted_identifier in Goset ansi_nulls on gocreate PROCEDURE dbo. Elmah_logerror (@ErrorId uniqueidentifier, @Application NVARCHAR ( -), @Host NVARCHAR ( -), @Type NVARCHAR ( -), @Source NVARCHAR ( -), @Message NVARCHAR ( -), @User NVARCHAR ( -), @AllXml NTEXT, @StatusCode INT, @TimeUtc DATETIME) ASSET NOCOUNT oninsertinto elmah_error (Er Rorid, Application, Host, Type, Source, Message, [User], Allxml, S Tatuscode, TIMEUTC) VALUES (@ErrorId, @Application, @Host, @Type, @Source , @Message, @User, @AllXml, @StatusCode, @TimeUtc) goset quoted_identifier OFF Goset ANSI_NULLS on GO
Elmah Log Component Database script