Login 'XXX' owns one or more database(s). Change the owner of the database(s) before dropping the login.

Login 'XXX' owns one or more database(s). Change the owner of the database(s) before dropping the login.

1.Use below commands to check which database has owned by login 'XXX'

select name [database], suser_sname(sid) [owner] from master.dbo.sysdatabases

2.Use below commands to change the db owner to login sa

USE [Tst]
GO
EXEC dbo.sp_changedbowner @loginame = N'sa', @map = false
GO

3.After that ,you can drop the logins
原文地址:https://www.cnblogs.com/JinweiChang/p/14690024.html