Find-sqmDatabaseObject
Database
sqmSQLTool v1.8.2+ · Query
Searches are performed on
sys.objects (by name) and optionally sys.sql_modules (by definition text). Database and object-type filters support wildcards.
Parameters
| Parameter | Type | Required | Default | Notes |
|---|---|---|---|---|
| -ObjectName | string | Required | — | Object name or wildcard pattern (e.g. sp_GetOrders, *log*). |
| -SqlInstance | string | Optional | $env:COMPUTERNAME | Target SQL Server instance. |
| -SqlCredential | PSCredential | Optional | — | Credentials for the connection. |
| -ObjectType | string[] | Optional | — | Restrict to types: TABLE, VIEW, PROCEDURE, FUNCTION, TRIGGER, SYNONYM. Multiple allowed. |
| -Database | string | Optional | * = all user DBs | Database name or wildcard pattern (e.g. Sales*). |
| -IncludeSystem | switch | Switch | $false | Include system databases (master, model, msdb). |
| -SearchDefinition | switch | Switch | $false | Also search object definitions (slower). |
| -EnableException | switch | Switch | $false | Re-throw exceptions instead of logging warnings. |
Execution Flow
Examples
Find a stored procedure by name
Find-sqmDatabaseObject -SqlInstance "SQL01" -ObjectName "sp_GetOrders"
Search for all objects with name containing 'log' (tables and views only)
Find-sqmDatabaseObject -SqlInstance "SQL01" -ObjectName "*log*" -ObjectType "TABLE","VIEW" -Database "Sales*"
Search object definitions (in addition to names)
Find-sqmDatabaseObject -SqlInstance "SQL01" -ObjectName "old_table_name" -SearchDefinition