获取登录名数据库实例级权限

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=)

分享标题:获取登录名数据库实例级权限
本文URL:http://csdahua.cn/article/ijiicg.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流