Synopsis

Invokes a sql statement and returns records affected.

Syntax

Invoke-SqlUpdate [-Query] <String> [[-Parameters] <Hashtable>] [-ConnectionName <String>] [-CommandTimeout <Int32>] [<CommonParameters>]

Invoke-SqlUpdate [-Command] <IDbCommand> [-ConnectionName <String>] [<CommonParameters>]

Description

Invokes a sql statement and returns records affected.

Parameters

-Query <String>

SQL statement to run.

Required? True
Position? 1
Default value  
Accept pipeline input? false
Accept wildcard characters? False

-Parameters <Hashtable>

Parameters required by the query. Key matches the parameter name, Value is the value of the parameter.

Required? False
Position? 2
Default value  
Accept pipeline input? true (ByValue)
Accept wildcard characters? False

-ConnectionName <String>

User defined name for connection.

Required? False
Position? named
Default value Default
Accept pipeline input? false
Accept wildcard characters? False

-CommandTimeout <Int32>

The timeout for this SQL statement, defaults to the command timeout for the SqlConnection.

Required? False
Position? named
Default value -1
Accept pipeline input? false
Accept wildcard characters? False

-Command <IDbCommand>

A IDbCommand object (with commandText and parameters, if required, already specified).

Required? True
Position? 1
Default value  
Accept pipeline input? true (ByValue)
Accept wildcard characters? False

<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

Examples

Example 1

PS C:\> Invoke-SqlUpdate -Query "DELETE FROM someTable"
1532

Invokes a sql statement and returns records affected.

Last edited Jun 23, 2015 at 1:30 PM by mastertook, version 2