NAnt Help Task Reference <sql> | NAnt.Contrib.Tasks () |
A task to execute arbitrary SQL statements against a OLEDB data source.
You can specify a set of sql statements inside the sql element, or execute them from a text file that contains them. You can also choose to execute the statements in a single batch, or execute them one by one (even inside a transaction, if you want to).Attribute | Type | Description | Required |
---|---|---|---|
connstring | string | Connection string used to access database. This should be an OleDB connection string. | True |
delimiter | string | String that separates statements from one another. | True |
delimstyle | NAnt.Contrib.Util.DelimiterStyle | Kind of delimiter used. Allowed values are Normal or Line. | True |
batch | bool | If true, the statements will be executed as a single batch. If false, they will be executed one by one. Default is true. | False |
cmdtimeout | int | Command timeout to use when creating commands. | False |
expandprops | bool | If true, the any nant-style properties on the sql will be expanded before execution. Default is true. | False |
output | string | If set, the results from the statements will be output to the specified file. | False |
bool | If set to true, results from the statements will be output to the build log. | False | |
source | string | File where the sql statements are defined. | False |
transaction | bool | If set to true, all statements will be executed within a single transaction. The default is true. | False |
failonerror | bool | False | |
if | bool | False | |
unless | bool | False | |
verbose | bool | False |
Execute a set of statements inside a transaction.
<sql connstring="Provider=SQLOLEDB;Data Source=localhost; Initial Catalog=Pruebas; Integrated Security=SSPI" transaction="true" delimiter=";" delimstyle="Normal" > INSERT INTO jobs (job_desc, min_lvl, max_lvl) VALUES('My Job', 22, 45); INSERT INTO jobs (job_desc, min_lvl, max_lvl) VALUES('Other Job', 09, 43); SELECT * FROM jobs; </sql>
Execute a set of statements from a file and write all query results to a file.
<sql connstring="Provider=SQLOLEDB;Data Source=localhost; Initial Catalog=Pruebas; Integrated Security=SSPI" transaction="true" delimiter=";" delimstyle="Normal" print="true" source="sql.txt" output="${outputdir}/results.txt" />
Execute a SQL script generated by SQL Server Enterprise Manager.
<sql connstring="Provider=SQLOLEDB;Data Source=localhost; Initial Catalog=Pruebas; Integrated Security=SSPI" transaction="true" delimiter="GO" delimstyle="Line" print="true" source="pubs.xml" batch="false" output="${outputdir}/results.txt" />