In the NantContrib doc located in the doc at:  nant\doc\help\nantContribTasks
 
<snip>
 

<sql> Task

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).

Parameters

Attribute Description Required
connstring Connection string used to access database. This should be an OleDB connection string. True
source File where the sql statements are defined. False
delimiter String that separates statements from one another. True
batch If true, the statements will be executed as a single batch. If false, they will be executed one by one. Default is true. False
expandprops If true, the any nant-style properties on the sql will be expanded before execution. Default is true. False
cmdtimeout Command timeout to use when creating commands False
delimstyle Kind of delimiter used. Allowed values are Normal or Line. True
print If set to true, results from the statements will be output to the build log. False
output If set, the results from the statements will be output to the specified file. False
transaction If set to true, all statements will be executed within a single transaction. Default value is true. False
failonerror False
verbose False
if False
unless False

Examples

Execute a set of statements inside a transaction

                 <sql
                    connstring="Provider=SQLOLEDB;Data Source=localhost; Initial Catalog=Pruebas; Integrated Security=SSPI"
                    transaction="true"
                    delimiter=";"
                 >
                    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=";"
                    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"
                 />
<snip/>


Monrozi�s_Pierre_Jean <[EMAIL PROTECTED]> wrote:

Hello,

 

I spend many time this week end looking for a tutorial on excuting sql script with nant. I effectively found some blogs which explain that it is possible with the <sql> nantContrib�s  task. But on the nantContrib site I found nothing more on this kind of task. What to do to use the sql task? Do you know a sample which could help me to practice.

 

Sincerly,

 

Piere jean


Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

Reply via email to