Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Drop User from all databases on a server -
- EXEC sp_Msforeachdb "IF EXISTS (SELECT * FROM sys.database_principals WHERE name = N'USERNAME') DROP USER [USERNAME]"
- GO
- --Drop the login -
- IF EXISTS (SELECT * FROM sys.server_principals WHERE name = N'USERNAME') DROP LOGIN [USERNAME]
- GO
Advertisement
Add Comment
Please, Sign In to add comment