Skip to content

Invoke SqlUpdate

mithrandyr edited this page Mar 22, 2018 · 2 revisions

Synopsis

Executes a query and returns number of record affected.

Description

Executes a query against the targeted connection and returns the the number of records affected.

Parameters

Mandatory = YES|NO|<default value>

Name Type Mandatory Description
ConnectionName String "default" User defined name for the connection
Query String "default" SQL statement to run.
Parameters Hashtable Parameters required by the query. Key matches the parameter name, value is the value of the parameter.
CommandTimeout Integer -1 The timeout, in seconds, for this SQL statement, defaults (-1) to the command timeout for the SqlConnection.

Examples

Invoke-SqlUpdate -Query "TRUNCATE TABLE employees"

Invoke-SqlUpdate -Query "UPDATE employees SET salary = @val WHERE manager = @managerId" -Parameters @{val = 999999; managerId = 549}