27 May 2024

MS SQL Server - Login Database

 A login is a simple credential for accessing SQL Server. For example, you provide your username and password when logging on to Windows or even your e-mail account. This username and password builds up the credentials. Therefore, credentials are simply a username and a password.

SQL Server allows four types of logins −

  • A login based on Windows credentials.
  • A login specific to SQL Server.
  • A login mapped to a certificate.
  • A login mapped to asymmetric key.

In this tutorial, we are interested in logins based on Windows Credentials and logins specific to SQL Server.

Logins based on Windows credentials allow you to log in to SQL Server using a Windows username and password. If you need to create your own credentials (username and password,) you can create a login specific to SQL Server.

To create, alter, or remove a SQL Server login, you can take one of two approaches −

  • Using SQL Server Management Studio.
  • Using T-SQL statements.

Following methods are used to create Login −

First Method – Using SQL Server Management Studio

Step 1 − After connecting to SQL Server Instance, expand logins folder as shown in the following snapshot.

Login Database

Step 2 − Right-click on Logins, then click Newlogin and the following screen will open.

Login New

Step 3 − Fill the Login name, Password and Confirm password columns as shown in the above screen and then click OK.

Login will be created as shown in the following image.

Test Login

Second Method – Using T-SQL Script

Create login yourloginname with password='yourpassword'

To create login name with TestLogin and password ‘P@ssword’ run below the following query.

Create login TestLogin with password='P@ssword'

MS SQL Server - Management Studio

 SQL Server Management Studio is a workstation component\client tool that will be installed if we select workstation component in installation steps. This allows you to connect to and manage your SQL Server from a graphical interface instead of having to use the command line.

In order to connect to a remote instance of an SQL Server, you will need this or similar software. It is used by Administrators, Developers, Testers, etc.

The following methods are used to open SQL Server Management Studio.

First Method

Start → All Programs → MS SQL Server 2012 → SQL Server Management Studio

Second Method

Go to Run and type SQLWB (For 2005 Version) SSMS (For 2008 and Later Versions). Then click Enter.

SQL Server Management Studio will be open up as shown in the following snapshot in either of the above method.

Management Studio

Union Budget 2024-25 – All You Need to Know

  Union Budget 2024-25 – All You Need to Know The Union Budget is a yearly financial plan presented by the Finance Minister of India for the...