Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I execute SQL scripts using TeamCity?

I´m new with TeamCity and I don´t know how to run SQL scripts with it.

Is the way simply selecting the path of those scripts in a Command Line Build Runner ?

I´m pretty lost.

Regards.

like image 597
luisen Avatar asked Feb 04 '14 14:02

luisen


2 Answers

In a command line build step:

Command executable: c:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe Command 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.

like image 70
John Hoerr Avatar answered Sep 19 '22 11:09

John Hoerr


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

like image 35
Evolve Software Ltd Avatar answered Sep 19 '22 11:09

Evolve Software Ltd