Drop User from SQL Server Database?

sanjeev40084 picture sanjeev40084 · Jan 7, 2010 · Viewed 100.5k times · Source

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.

Answer

doug_w picture doug_w · Jan 7, 2010

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.