SQL Server-Drop login

Msg 50000, Level 16, State 127, Line 280

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/roseHLF/p/7144638.html