+ -
当前位置:首页 → 问答吧 → sql server2005如何查询一个登录名的权限。

sql server2005如何查询一个登录名的权限。

时间:2011-12-13

来源:互联网

使用sa登录sql server2005,怎样查询一个登录名有哪些读写权限以及能够操作哪些表?

作者: speedk8   发布时间: 2011-12-13

sp_helprotect

作者: Beirut   发布时间: 2011-12-13

-- 查询当前数据库用户账户的权限
select object_name(id) obj,
(case [action] when 26 then 'REFERENCES'
 when 178 then 'CREATE FUNCTION'
 when 193 then 'SELECT'
 when 195 then 'INSERT'
 when 196 then 'DELETE'
 when 197 then 'UPDATE'
 when 198 then 'CREATE TABLE'
 when 203 then 'CREATE DATABASE'
 when 207 then 'CREATE VIEW'
 when 222 then 'CREATE PROCEDURE'
 when 224 then 'EXECUTE'
 when 228 then 'BACKUP DATABASE'
 when 233 then 'CREATE DEFAULT'
 when 235 then 'BACKUP LOG'
 when 236 then 'CREATE RULE' end) perm
from sysprotects where [uid]=user_id()

作者: dawugui   发布时间: 2011-12-13

SQL code
--sql 2000
-- 查询当前数据库用户账户的权限
select object_name(id) obj,
(case [action] when 26 then 'REFERENCES'
 when 178 then 'CREATE FUNCTION'
 when 193 then 'SELECT'
 when 195 then 'INSERT'
 when 196 then 'DELETE'
 when 197 then 'UPDATE'
 when 198 then 'CREATE TABLE'
 when 203 then 'CREATE DATABASE'
 when 207 then 'CREATE VIEW'
 when 222 then 'CREATE PROCEDURE'
 when 224 then 'EXECUTE'
 when 228 then 'BACKUP DATABASE'
 when 233 then 'CREATE DEFAULT'
 when 235 then 'BACKUP LOG'
 when 236 then 'CREATE RULE' end) perm
from sysprotects where [uid]=user_id()

--sql 2005
EXECUTE AS LOGIN = 'sa';  
SELECT * FROM fn_my_permissions(NULL, 'DATABASE');  
REVERT;

作者: dawugui   发布时间: 2011-12-13

引用 3 楼 dawugui 的回复:
SQL code
--sql 2000
-- 查询当前数据库用户账户的权限
select object_name(id) obj,
(case [action] when 26 then 'REFERENCES'
when 178 then 'CREATE FUNCTION'
when 193 then 'SELECT'
when 195 then 'INSERT'
whe……


+1

作者: liuqian4243   发布时间: 2011-12-13

热门下载

更多