I am trying to find the stored procedure from my application and finding function and sub function along with views for redesigning the application in SQL Server 2014. What I am trying is taking lots of time and I want to find with the help of SQL query like this:
SELECT
OBJECT_NAME(object_id),
OBJECT_DEFINITION(object_id)
FROM
sys.procedures
WHERE
OBJECT_DEFINITION(object_id) LIKE '%fn%'
This is retrieving all the stored procedures which is using functions. My requirement is as follows:
My naming convention are as follows:
P_*
for stored procedureFN_*
for functionVW_*
for viewsMy application is huge so manually finding stored procedure are easy but finding functions and views are really takes time.
You can use sp_depends
to get a list of dependent objects (including functions) for a particular stored procedure using T-SQL.
In SSMS you can right-click on your particular stored procedure in the Object Explorer and choose View Dependencies item in the context menu:
This will open a window with the tree of dependent objects, including functions: