Friday, September 30, 2016

How to check my permission on SQL Server object

How do you check and see whether you have permission on a specific object and what permission types you have been granted? This requirement comes whenever you experience a permission issue and it might not be easy to get relevant information from relevant department or person. However, SQL Server offers a function for us: fn_my_permissions. This function can be used for seeing all permissions you have been granted on a particular object;

  1. <div style="text-align: justify;">  
  2. SELECT * FROM fn_my_permissions (NULL'DATABASE');  </div>  
  3. USE AdventureWorks2014;  
  4. GO  
  5.   
  6. <div style="text-align: justify;">  
  7. SELECT * FROM fn_my_permissions('Sales.SalesOrderHeader''OBJECT') ;</div>  


This function accepts securable and securable class. There are multiple classes such as DATABASE, SCHEMA, OBJECT etc.


No comments: