---
title: "Execute Database Statement"
---
Executes a statement against a database.
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.
Name | Format | Script Usage | Usage 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". |
Execute-DatabaseStatement (
Statement: >>
print 'Executing BuildMaster statement...'
select * from sys.databases
where owner_sid > 1
order by name
print 'Execution complete.'
>>,
Connection: SqlServerTesting
);