Okay, so I have a .build file that contains targets to execute specific tasks to build a solution. Say I have .sql file in a folder that I want to run. I need to use .build file to run this sql script. How can I create the target? More precisely, this is what I have and what I need
<target name="run.sql.script" description ="will run my script">
<exec program="what goes here??" commandline="-d mydb -S myserverinstance i C:\mysqlscript.sql">
</target>
If it matters at all, I want to run the script against sql server 2008 R2
Thanks,
The magic question was how would you run this from a command-line? You probably want to look at osql.exe
(older) or sqlcmd.exe
(newer) in C:\Program Files\Microsoft SQL Server\{version}\Tools\Binn
See http://blog.sqlauthority.com/2009/01/05/sql-server-sqlcmd-vs-osql-basic-comparison/ for a comparison.
Run like this:
sqlcmd -S myServer\instanceName -i C:\myScript.sql