I have a folder full of SQL utility scripts which I’ve compiled over the years. One of which would search all stored procedures within a given database for instances of a specified string. This type of script is really helpful if you need to find all routines which reference a specific table column. This morning I extended the routine to include views and user-defined functions as well. I also made a change to include all databases on the SQL Server except of the four system databases.
Notice the script used PATINDEX(). What does it do? It returns the starting position of the first occurrence of a pattern in a specific expression, or zero if the pattern is not found, on all valid text and character data types. You may have noticed the expression sought by PATINDEX() must be enclosed in “%” signs. but within the expression we could use wildcards “%” for any number of letters, “_” for a single character,  to specify a range of characters and [^] to skip a range, just as you do when using LIKE comparisons.