Error Message:
Msg 297, Level 16, State 1, Line 1
The user does not have permission to perform this action.
Reason:
This error occurs when the user does not have permission to execute a specific query.
Example:
Revoke view state permission to user
REVOKE VIEW SERVER STATE TO user_name
You will get the error message 297 when you execute this query to fetch the index usage stats
select * from sys.dm_db_index_usage_stats
Fix/Resolution:
Provide the required permissions to the user.
GRANT VIEW SERVER STATE TO user_name
Note: replace user_name with the name of the user.