We have implemented Availability Groups and it brought up a question. We previously used database auditing to see which objects are used in production. Now with the AG we can have an audit on the database on both servers BUT each server needs to be the primary when adding or removing objects from the audit (You can't alter on the readonly copy). This would require failing over every time we need to change the audit.
Example:
- Server A is primary
- Create Server and Database audit
- Add all objects to the audit
- Failover so that Server B is primary
- Create Server and Database audit
- Add all objects to the audit
- Monitor audit
- Remove objects that are found to be used from the audit (Server B)
- Failover so that Server A is primary
- Remove objects that are found to be used from the audit (Server A)
- Rinse and Repeat
This isn't a viable solution for us as the audit file will get extremely large very quickly. We can't failover often either and only at very specific times.
Question: Is there a better way to see ALL the objects (SPs, functions, views, tables, etc.) that are being used in the database?