SQL Table to store the Logon History

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[UserLogonHistory](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[LogonDateTime] [datetime] NOT NULL CONSTRAINT [DF_LogonUserHistory_When] DEFAULT (getdate()),
	[UserID] [int] NOT NULL,
	[Message] [nvarchar](255) NULL,
CONSTRAINT [PK_UserLogonHistory] PRIMARY KEY CLUSTERED ([ID] ASC)
	WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]

 GO

ALTER TABLE [dbo].[UserLogonHistory] WITH CHECK ADD CONSTRAINT [FK_UserLogonHistory_User]
	FOREIGN KEY([UserID]) REFERENCES [dbo].[User] ([ID])
GO

ALTER TABLE [dbo].[UserLogonHistory] CHECK CONSTRAINT [FK_UserLogonHistory_User]
GO

Post a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s