Deleting an Existing Login in SQL Server 2008

In this article I will explain how to delete existing login account in SQL Server through different methods.
  • 2744

Introduction

Login is used for security purpose. Users need login to access SQL Server. Login can be created based on windows principal such as SQL Server Authentication or Windows authentication. Login must be mapped to a database user to connect to a particular database. There are 3 ways to remove a SQL Server login account.

  1. Using SQL Server Management Studio.
  2. Using SQL query.
  3. Using system stored procedure

Deleting a Login using SQL Server Management Studio

Step 1

Open SQL Server Management Studio and connect to database engine.

Step 2

In object explorer step down to the Security object node. Right-click on login name which you want to delete. Select delete to delete the login.

Delete login using Management Studio.jpg

Step 3

Refresh the login node and see, selected node is deleted.

NEW LOGIN deleted.jpg

Deleting a Login using SQL Statement

To drop a login from SQL Server via SQL statement,  use following syntax:

DROP LOGIN login_name

where login_name specifies the existing login name which you want to delete.

Suppose you want to delete login named "NEW LOGIN".

drop login [NEW_LOGIN];

Output:

command executed successfully.jpg

Refresh login node.

NEW_LOGIN deleted.jpg

Deleting a Login using Stored Procedure

Syntax:

exec sp_droplogin 'user'

where user specifies the login name which you want to delete.

EXEC sp_droplogin 'LOGIN'

Output:

command executed successfully.jpg

Refresh login node. LOGIN user has been deleted.

 LOGIN deleted.jpg

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.