-
Notifications
You must be signed in to change notification settings - Fork 64
sql_cmd
Run SQL scripts & commands using SQL Server's sqlcmd.exe application. This task only supports a subset of commonly used commands, please contribute more!
desc "Create the initial database"
sql_cmd :create do |cmd|
cmd.server = "myserver"
cmd.database = "somedatabase"
cmd.trusted_connection
cmd.scripts = ["create.sql", "update.sql"]
cmd.exe = "path to sqlcmd"
end
##Server & Database
The name of the server and database to connect to and use. By default, sqlcmd uses the default instance on localhost.
server = "myserver" database = "somedatabase"
If you have to pass an instance name, it requires a backslash. So, it must be escaped, by using a double-backslash.
server = "myserver\myinstance" Username & Password OR Trusted Connection
##The username and password to connect as.
username = "Someone" password = "FooBar"
Or, you can login with Windows integrated security. Without any authentication parameters, sqlcmd uses a trusted connection implicitly, so this is often not required at all.
##Trusted Authentication (Windows)
This specifies to use a windows authenticated connection to the server & database, if set, the username and password parameters are removed.
trusted_connection
##Scripts
The script files for sqlcmd to execute.
scripts = ["script1.sql", "script2.sql"]