获取登录名数据库实例级权限
SELECT 'EXEC master..sp_addsrvrolemember @loginame = N'''+loginname+''', @rolename = N'''+priv+''''
FROM
(
SELECT loginname, priv, value
FROM
(
SELECT loginname, sysadmin, securityadmin, serveradmin, setupadmin, processadmin, diskadmin, dbcreator, bulkadmin
FROM sys.syslogins
) AS a UNPIVOT(value FOR priv IN(sysadmin, securityadmin, serveradmin, setupadmin, processadmin, diskadmin, dbcreator, bulkadmin)) AS UPV
) AS T
WHERE VALUE = 1;
![](/upload/otherpic45/171158.jpg?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
当前名称:获取登录名数据库实例级权限
文章路径:http://pwwzsj.com/article/ijiicg.html