EXEC sp_Msforeachdb "USE [?]; IF EXISTS (SELECT * FROM sys.database_principals WHERE name = N'USERNAME') DROP USER [USERNAME]" GO
IF EXISTS (SELECT * FROM sys.server_principals WHERE name = N'USERNAME') DROP LOGIN [USERNAME] GO
Missing a '?' in there. Like USE ? Otherwise it won't look anywhere but at the current db.
thank you, good spot.
Post a Comment
2 comments:
Missing a '?' in there. Like USE ? Otherwise it won't look anywhere but at the current db.
thank you, good spot.
Post a Comment