dbatools is a free PowerShell module with over 180 SQL Server administration, best practice and migration commands included.


Find-DbaStoredProcedure

Returns all stored procedures that contain a specific case-insensitive string or regex pattern.

This function can either run against specific databases or all databases searching all user or user and system stored procedures.

Screenshots

Examples

To search in all user databases stored procedures for “whatever” in the textbody

Find-DbaStoredProcedure -SqlServer DEV01 -Pattern whatever

To search all databases for all stored procedures that contain a valid email pattern in the textbody

Find-DbaStoredProcedure -SqlServer sql2016 -Pattern ‘\w+@\w+.\w+’

To search in “mydb” database stored procedures for “some string” in the textbody

Find-DbaStoredProcedure -SqlServer DEV01 -Databases MyDB -Pattern ‘some string’ -Verbose

To search in ALL stored procedures in the “mydb” database for “runtime” in the textbody

Find-DbaStoredProcedure -SqlServer sql2016 -Databases MyDB -Pattern RUNTIME -IncludeSystemObjects

Author

This command was created by Stephen Bennett. You can find Stephen blogging at sqlnotesfromtheunderground.wordpress.com.

Get-Help

From PowerShell, execute Get-Help Find-DbaStoredProcedure -Detailed for more information on this function.

Source Code

Want to see the source code? View Find-DbaStoredProcedure.ps1 on GitHub
 

Related commands