Internet Explorer is no longer supported. Many things will still work, but your experience will be degraded and some things won't function. Please use a modern browser such as Edge, Chrome, or Firefox.

Execute Database Statement

Executes a statement against a database.

Script usage:

Execute-DatabaseStatement(
	Connection: <text>,
	Statement: <text>,
	[LogStatement: <true/false>]
);

This operation may be prefixed with Core::, although this is a built-in namespace and isn't really necessary.

Arguments:

NameFormatScript UsageUsage Notes
Database connection
text
Connection
This argument is required.
SQL Statement
text
Statement
This argument is required.
Log statement to execute
true/false
LogStatement
Default value is "True".

Example:


Execute-DatabaseStatement (
    Statement: >>
    print 'Executing BuildMaster statement...'

    select * from sys.databases
    where owner_sid > 1
    order by name

    print 'Execution complete.'
>>,
    Connection: SqlServerTesting
);