Automated DevOps deployments

The guide walks you through the following how-to topics:

Deploy changes with the Schema Compare command line

1. Create a copy of the scripts folder on your local machine or check it out from source control.

2. Deploy the local scripts folder to the target database.

For more detailed instructions, see deploying a scripts folder with the dbForge Schema Compare command line.

Deploy changes using DevOps Automation

The dbForge DevOps Automation for SQL Server product has a PowerShell cmdlet allowing you to compare and synchronize a required scripts folder with the target database.

To learn more about deploying a database using the cmdlet, please refer to our DevOps Automation for SQL Server documentation.

Deploy changes with a batch file from a scripts folder

1. Create a batch file with the following content:

sqlcmd -S "server"-U "login"-P "password"-i "input_file" 
PAUSE 

where input_file is a path to the SQL file that will create the database.

2. Create a single SQL file that contains a script to add a new database. For example, the script can be as follows:

SET NOCOUNT ON
 GO
 PRINT 'Creating sales_demo1 database'
 USE [master]
 GO
 DECLARE @db_name NVARCHAR(255);
 SET @db_name = N'sales_demo';
 IF EXISTS (SELECT 1 FROM sys.databases d WHERE d.name = @db_name)
 BEGIN
   EXEC (N'ALTER DATABASE '+@db_name+N' SET SINGLE_USER WITH ROLLBACK IMMEDIATE');
   EXEC (N'DROP DATABASE '+@db_name);
 END;
 EXEC (N'CREATE DATABASE '+@db_name);
 GO
 USE sales_demo
 GO
 :On Error exit
 :r "D:\sales_demo\Tables\dbo.Customers.sql"
 :r "D:\sales_demo\Tables\dbo.OrderLines.sql"
 :r "D:\sales_demo\Tables\dbo.Orders.sql"
 :r "D:\sales_demo\Tables\dbo.Products.sql"
 PRINT 'Creation is Completed'
 GO

where :r is a SQLCMD command that parses additional Transact-SQL statements and SQLCMD commands from the file specified by <filename> into the statement cache.

3. Launch the command prompt and execute the batch file you’ve created.

To learn more about how to deploy a database from Source Control, see How to Build a Database from Source Control.

To learn about how to deploy a database from source control using dbForge Schema Compare, see Deploy a database from the source control.

Want to Find out More?

Overview

Overview

Take a quick tour to learn all about the key benefits delivered by dbForge Source Control for SQL Server.
All Features

All features

Get acquainted with the rich features and capabilities of the Source Control in less than 5 minutes.
Request a demo

Request a demo

If you consider employing the Source Control for your business, request a demo to see it in action.
Ready to start using dbForge Source Control for SQL Server?