Thursday, 23 May 2019

Find any word written in all Stored Procedures or Functions in MS SQL Server

1. Query for Just find in Stored Procedures

SELECT Name
FROM sys.procedures

WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%Your Word%'


2.Query for Just find in Stored Procedures and Functions

select distinct [Table Name] = o.Name, [Found In] = sp.Name, sp.type_desc
  from sys.objects o inner join sys.sql_expression_dependencies  sd on o.object_id = sd.referenced_id
                inner join sys.objects sp on sd.referencing_id = sp.object_id
                    and sp.type in ('P', 'FN')
  where o.name = 'Your Word'
  order by sp.Name


No comments:

Post a Comment