前因后果是这样的:
我backup了2005的一个数据库,到另一台机器的sqlserver2005上restore了。发现里面的一个用户无法连接这个数据库。
所以我打算把数据库里的这个用户删掉,再重新建一个login。
结果发吸这个用户删不掉,报错信息:
TITLE: Microsoft SQL Server Management Studio
------------------------------Drop failed for User 'abs'. (Microsoft.SqlServer.Smo)For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1399.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Drop+User&LinkId=20476------------------------------
ADDITIONAL INFORMATION:An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)------------------------------The database principal owns a database role and cannot be dropped. (Microsoft SQL Server, Error: 15421)For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=15421&LinkId=20476------------------------------
BUTTONS:OK
------------------------------
这个用户的Owned Schema列表里一个shcema也没有勾,同样Database role membership也都清了,没有勾。
default shcema那里写的是dbo(这个我清不掉)为什么点delete删不掉呢?
我backup了2005的一个数据库,到另一台机器的sqlserver2005上restore了。发现里面的一个用户无法连接这个数据库。
所以我打算把数据库里的这个用户删掉,再重新建一个login。
结果发吸这个用户删不掉,报错信息:
TITLE: Microsoft SQL Server Management Studio
------------------------------Drop failed for User 'abs'. (Microsoft.SqlServer.Smo)For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1399.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Drop+User&LinkId=20476------------------------------
ADDITIONAL INFORMATION:An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)------------------------------The database principal owns a database role and cannot be dropped. (Microsoft SQL Server, Error: 15421)For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=15421&LinkId=20476------------------------------
BUTTONS:OK
------------------------------
这个用户的Owned Schema列表里一个shcema也没有勾,同样Database role membership也都清了,没有勾。
default shcema那里写的是dbo(这个我清不掉)为什么点delete删不掉呢?
解决方案 »
- 一个小问题
- 帮忙写个数据库初始化sql,把一个时间段内的周六日插进某张表;万分感谢!
- 怎样将sql2005数据库备份成.mdf 谢谢
- SQL如何做统计报表,并与其他表做关联?
- 【求助】微软下载的SQL Server Management Studio Express为何没有中文版?
- 一个关于update的问题
- 如何实现按条件分类汇总,数据如下:
- 各位大侠帮俺看看这段错误记录在(线等....)
- restore master db failed on cluster sql server 2000
- 请教
- SQL Server 任务调度时间如果修改?
- 如何把sql文件导入到sqlserver2005中
go
drop user 数据库用户
drop Login 登陆名
---数据库用户/登陆名 一般情况下是相同的
Msg 15421, Level 16, State 1, Line 1
The database principal owns a database role and cannot be dropped.
select * from sys.objects where schema_id = (select schema_id from sys.schemas where name = 'test')
--如果有就需要先删掉以后才能删除用户
在查看实例中的数据库—用户(删除)
------
如果用户是db_owner在多个数据库时,要在各个数据里的用户名删除
其次,可以试试Exec sp_change_users_login 'Auto_Fix',UserName,null
2005中也应该有类似的方法吧
首先这个sql server developer版是新装的。除了系统库外只有我这一个用户数据库。另外我认为既然login已经删掉了,我现在对付的是具体的一个数据库里的user,应该不需要考虑其它数据库吧。to zpzpyesterday :
Exec sp_change_users_login 'Auto_Fix',UserName,null
这个怎么用?因为根本没有对应的login 。