How can I execute SQL scripts using TeamCity? How can I execute SQL scripts using TeamCity? sql sql

How can I execute SQL scripts using TeamCity?


In a command line build step:

Command executable: c:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exeCommand parameters: -S <server> -i <path_to_file> <== Note: that's a capital -S!

You may need to change the 100 to something else, depending on the version of the SQL Server tools that you have installed on the build agent.


I believe that SQLCMD / SQLPLUS / MYSQL are available as standalone executables which you can install on the TeamCity server.

Microsoft® SQL Server® 2008 R2 Feature Pack

Oracle SQL Plus

MYSQL Command Line

However, without knowing your actual SQL Platform this may differ and the provider should have an alternative.

You can then create a Command Line Runner to call the executeable and pass in the parameters required, which are further explained here.

Using the sqlcmd Utility

Using sqlplus utility

If you are looking at doing Database Migrations as part of your CI process, it would also be worth checking out RoundhousE