locked
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];
    GO
    sp_helpuser @name_in_db =  'specific_user'

    Then:

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

    Reference:
    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.

    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/7daddfdc-f982-4a46-8e48-652b1029e83d/find-users-in-sqlserver-2012?forum=sqlsearch#7daddfdc-f982-4a46-8e48-652b1029e83d

    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
    DallasDBAs

    Wednesday, January 18, 2017 4:40 PM