Select
name,'GRANT SELECT ON ' + RTRIM(name) +' TO hrquerry_R' as 授权语句 ,type_desc
From
sys.all_objects
Where
name not in( 'hm','hr_1','hr_2','gzqt') --排除 hm,hr_1,hr_2,gzqt 表的授权
And (type_desc = 'USER_TABLE' Or type_desc = 'VIEW') --取所有表与视图
And schema_id = 1 --只取用户表与视图