Search and delete specific users. RRS feed

  • Question

  • Hello.

    I have a web portal that used SQL Server as DB and users can use my web portal for create account and... How can I find specific users in my DB and remove them?

    Thank you.

    Wednesday, January 18, 2017 1:30 PM

All replies

  • Hello,

    We don't know your database design, so how could we tell in which table(s) user / account informations are stored?

    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Wednesday, January 18, 2017 2:15 PM
  • How about?

    USE [MyDB];
    sp_helpuser @name_in_db =  'specific_user'


    sp_revokelogin [AD\user_account]; -- windows account
    sp_droplogin 'sql_login' -- sql account

    sp_helpuser (Transact-SQL)

    [Please mark as answer if this post helps you]

    Hope that helps, 

    Phil Streiff, MCDBA, MCITP, MCSA

    Wednesday, January 18, 2017 3:02 PM
  • Hello Windows.Geek,

    You asked the similar question from another forum.


    Your questions really don't make any sense. What do you really want to? Do you want to drop a Login using SQL Server Management Studio? Do you want to drop a Database User from a database using T-SQL or SQL Server Management Studio?

    If you want to progress with this question of yours, you really need to elaborate your requirement.

    http://ekremonsoy.blogspot.com | http://www.ekremonsoy.com | @EkremOnsoy

    Wednesday, January 18, 2017 3:48 PM
  • I am also not quite clear about what you are doing, but SQL Server logins can be listed by using the Transact-SQL statement SELECT * FROM sys.server_principals; Or users in a specific database can be listed using the Transact-SQL statement SELECT * FROM sys.database_principals;

    Or you can use SQL Server Management Studio to view both logins and users.

    Rick Byham, Microsoft, SQL Server Books Online, Implies no warranty

    Wednesday, January 18, 2017 4:28 PM
  • Or, users could be stored in a user table in one or more databases, having nothing to do with SQL security :D

    22 years of database experience, most with SQL Server. Please 'Mark as answered' those posts that helped you.

    Kevin3NF on Twitter

    Wednesday, January 18, 2017 4:40 PM