Ways to log in database on MS SQL Server

Below are instructions on how to log into the database on MS SQL Server.

Logging in is a simple way to access SQL Server, as well as using your ID and password to log in to Windows or your email account. SQL Server has 4 types of login.

  1. According to Windows login information
  2. Specified specifically for SQL Server
  3. Created under Certificate certificate
  4. Created by Asymmetric Keys

This tutorial will only focus on how to log in with Windows Credentials and specify it for SQL Server.

Method 1 helps you log into SQL Server with your Windows username and password. If you want to create another username and password, use the second method.

To create, change or delete SQL Server login information, there are two ways

  1. Use SQL Server Management Studio
  2. Use T-SQL

Method 1: Log in to the database using SQL Server Management Studio

Step 1 : After connecting to SQL Server Instance, open the Logins folder as shown in the image below.

Ways to log in database on MS SQL Server Picture 1Ways to log in database on MS SQL Server Picture 1
Open the Logins folder on SQL Server Management Studio

Step 2: Right-click Logins and select Newlogin, the screen below will appear.

Ways to log in database on MS SQL Server Picture 2Ways to log in database on MS SQL Server Picture 2
Enter login information

Step 3: Enter the name and password, confirm the password again as shown in the image above and click OK. Then, new login information will be created as shown in the image below.

Ways to log in database on MS SQL Server Picture 3Ways to log in database on MS SQL Server Picture 3
New login information created

Method 2: Log in the database using T-SQL Script

To create a login name of TestLogin and a password of P @ ssword, you only need to run 2 queries below.

 Create login yourloginname with password='yourpassword' 
 Create login TestLogin with password='P@ssword' 

Previous article: Managing MS SQL Server with Management Studio

Next article: How to create a database on MS SQL Server

5 ★ | 2 Vote