How to Create a Login table in SQL

Hey there! Do you want to make a place for people to log in to your website? In this blog post, I will explain to you step by step how to create a login table with SQL.

Introduction

Open SQL Server Management Studio

Enter Username and Password.

Create New Database

Right click on Database folder and select New Database.

Enter the database name and click on OK button.

Use below code to create LoginUser table.

CREATE TABLE [dbo].[LoginUser](
	[UserID] [int] IDENTITY(1,1) NOT NULL,
	[UserName] [nvarchar](25) NULL,
	[FullName] [nvarchar](50) NULL,
	[UserEmail] [nvarchar](50) NULL,
	[Password] [nvarchar](50) NULL,
	[IsActive] [bit] NULL,
	[LoginTimeStamp] [datetime] NULL,
	[CreatedDate] [datetime] NULL,
 CONSTRAINT [PK_Login] PRIMARY KEY CLUSTERED 
(
	[UserID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[LoginUser] ADD  CONSTRAINT [DF_LoginUser_IsActive]  DEFAULT ((1)) FOR [IsActive]
GO

ALTER TABLE [dbo].[LoginUser] ADD  CONSTRAINT [DF_Login_LoginTimeStamp]  DEFAULT (getdate()) FOR [LoginTimeStamp]
GO

Other Post

  1. What is HTMX in 2024

Leave a Comment