Forum Discussion
vsslasd
Apr 10, 2024Copper Contributor
How to find the number of times a view was used within SQL Server
We are doing housekeeping in SQL Server and wanted to remove views that are no longer being used or needed.
To ascertain this, we wanted to assess the frequency of various view usage within select statements, stored procedures, etc. and hopefully their dates and counts of usage for a list of views
Then we will remove those that aren't being used.
What's the best way to do this?
Thank you
Then we will remove those that aren't being used. What's the best way to do this?
vsslasd , there is not a 100% reliable way to get know, where or uses views.
One way is to create a SSDT database project for this kind of re-engineering
Create a New Database Project - SQL Server Data Tools (SSDT) | Microsoft Learn
But even this isn't 100%, better rename the view first to see where it errors out, before you delete them.
- olafhelperBronze Contributor
Then we will remove those that aren't being used. What's the best way to do this?
vsslasd , there is not a 100% reliable way to get know, where or uses views.
One way is to create a SSDT database project for this kind of re-engineering
Create a New Database Project - SQL Server Data Tools (SSDT) | Microsoft Learn
But even this isn't 100%, better rename the view first to see where it errors out, before you delete them.