MD3.LogTable.sql 791 Bytes
Newer Older
dwentzel's avatar
dwentzel committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
IF NOT EXISTS (SELECT 1 FROM sys.objects
					 WHERE type ='u' AND object_id = OBJECT_ID('MD3.Log'))
BEGIN
	
	CREATE TABLE MD3.Log
	   (Id              BIGINT IDENTITY(1,1) NOT NULL
	   ,DTime           DATETIME2            NOT NULL
	   ,Severity             CHAR(1)         NOT NULL
	   ,ScriptName         NVARCHAR(256)        NULL
	   ,ProcName           NVARCHAR(256)        NULL
	   ,Message       NVARCHAR(MAX)        NOT NULL
	   ,ErrorMessage	NVARCHAR(MAX)		NULL
	   ,ErrorNumber		INT					NULL
	   ,ErrorLine		INT					NULL
	   ,ErrorSeverity	INT					NULL
	   ,ErrorState		INT					NULL
	);
	   
	ALTER TABLE MD3.Log ADD CONSTRAINT LogPK 
	PRIMARY KEY CLUSTERED (Id);

	ALTER TABLE MD3.Log WITH CHECK 
		ADD CONSTRAINT SeverityCheck
			CHECK (Severity IN ('D','I','W','E'));
		
END