For VIEW DEFINITION
/ VIEW ANY DEFINITION
you are probably fine given that the developers likely already have access to the source-code.
For VIEW SERVER STATE
, that does control access to a wide range of functionality, so you need to be more deliberate and cautious when granting this permission. The primary consideration is: How open-ended vs constrained does the access need to be? The issue is that there is no granularity to VIEW SERVER STATE
: it's either all or none.
Do the developers need full ad hoc query access, or do they simply need the ability to execute some number of pre-defined queries that you will provide? If they need full ad hoc query access then you will likely need to grant them VIEW SERVER STATE
. But, if you can get away with providing a limited number of queries, then you don't need to grant them anything (outside of EXECUTE
permission on the stored procedures that contain the queries that are providing). In this case you would grant the stored procedures the VIEW SERVER STATE
permission (and/or ALTER TRACE
permission). The developers would only be able to make use of those elevated permissions via the stored procedures. And, if any developer tries to get sneaky and update one of the stored procedures to make use of the elevated permission(s) in another way, then whatever stored procedures was updated would automatically lose the elevated permissions.
This is all possible via Module Signing. For an example, please see my answer to Execute Permissions for a Store Procedure that creates databases (also here on DBA.StackExchange).
Once you have this security mechanism in place (i.e. the certificate and the certificate-based login and/or user, depending on the scope of permissions you are needing to grant), it can be applied to any number of stored procedures, triggers, TVFs (except for inline), and UDFs. If a second permission is needed, then if the permission is always needed along with the initial permission, just add it to the same certificate-based principal (login and/or user). If the second permission is only needed in some cases, then create another certificate, and another certificate-based principal from the 2nd certificate, assign the other permission to the 2nd certificate-based principal, and execute ADD SIGNATURE
again, using the 2nd certificate, on the objects needing the other permission (you can add multiple signatures to objects, hence combining permissions).
VIEW SERVER STATE
.