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
posted @ 2021-04-22 15:51  JinweiChang  阅读(36)  评论(0编辑  收藏  举报