Search code examples
sqlsql-serveruser-management

Drop User from SQL Server Database?


How can I drop user from a database without dropping it's logging?

The script should check if the user exists in database, if does then drop the user.


Solution

  • Is this what you are trying to do??

    IF  EXISTS (SELECT * FROM sys.database_principals WHERE name = N'username')
    DROP USER [username]
    

    If you are using SQL Server Management Studio you can browse to the user and right-click selecting delete.