SET QUOTED_IDENTIFIER OFF
GO
-- Remove user from
each database where the account exists
EXEC sp_Msforeachdb "IF EXISTS (SELECT * FROM sys.database_principals WHERE name = N'DOMAIN\UserName')
DROP USER [DOMAIN\UserName]"
GO
-- Remove login from
this SQL Server
IF EXISTS (SELECT * FROM sys.server_principals WHERE name = N'DOMAIN\UserName') DROP LOGIN [DOMAIN\UserName]
GO
No comments:
Post a Comment