Elmah Log Component Database script

Source: Internet
Author: User
Tags rowcount

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.