John Egbert
John Egbert

Reputation: 5756

What is the SQL to delete a SQL User from a database?

What is the SQL to delete a SQL User from a database?

Upvotes: 1

Views: 124

Answers (1)

Martin Smith
Martin Smith

Reputation: 452957

 DROP USER [UserName]

You can prefix this with an existence check if required.

IF  EXISTS (SELECT * FROM sys.database_principals WHERE name = N'UserName')

There are some requirements to be met before dropping Users (e.g. they can't own any objects). Full Details here.

Upvotes: 4

Related Questions