我正在写一个将返回的查询
我想我需要查询master数据库并通过它来摆动以获取我正在寻找的数据库和表或存储过程。如果已将执行权限分配给该对象上的特定角色,我如何获得'true / false'?
答案 0 :(得分:8)
USE YourDatabase
/*To find out if it exists*/
SELECT OBJECT_ID('dbo.spFoo') /*Will be NULL if it doesn't exist or you don't have
permission to see the object*/
/*To find out the permissions on it take a look at the following system views*/
select * from sys.database_permissions p
inner JOIN sys.database_principals dp
on p.grantee_principal_id = dp.principal_id
where major_id=object_id('dbo.spFoo')