存档
以将dbo创建的所有表授予相应权限给普通用户userA为例。
将dbo拥有的表的相应权限(select/insert/update/delete)授予给普通用户userA,使用以下SQL生成授权语句:
select 'grant select on ' + user_name(uid) + '.' + name + ' to userA' from sysobjects where type='U' and uid=user_id('dbo')
union all
select 'grant insert on ' + user_name(uid) + '.' + name + ' to userA' from sysobjects where type='U' and uid=user_id('dbo')
union all
select 'grant update on ' + user_name(uid) + '.' + name + ' to userA' from sysobjects where type='U' and uid=user_id('dbo')
union all
select 'grant delete on ' + user_name(uid) + '.' + name + ' to userA' from sysobjects where type='U' and uid=user_id('dbo')
查看某张表的上用户的权限情况:
sp_helprotect table_name
查看用户所拥有的对象权限情况:
sp_helprotect user_name