Integrate SQL Complete into DevOps

dbForge SQL Complete can be involved in the DevOps process via PowerShell cmdlets that can help format scripts for creating and updating a database before they get into a NuGet package.

This topic covers the following:

To start using SQL Complete in the DevOps process, make sure that:

  • PowerShell version is 3.0 or later
  • dbForge DevOps Automation for SQL Server and dbForge SQL Complete are installed on your computer
  • You have SQL files to be formatted

Note

By default, PowerShell is installed on Windows 8, 8.1, and 10. For other versions, download PowerShell from the Microsoft official download center page.

To check the current version of PowerShell, open WindowsPowerShell ISE and execute the $PSVersionTable.PSVersion command. In the Major column, you can see the version currently installed on your computer.

Install dbForge DevOps Automation PowerShell for SQL Server

dbForge DevOps Automation for SQL Server is supplied as part of dbForge SQL Tools (Professional version) and includes dbForge DevOps Automation PowerShell for SQL Server.

1. Download the product from the Devart website.

2. Run the installer and follow the instructions in the Setup wizard.

After the installation is completed, the Devart.DbForge.DevOpsAutomation.SqlServer module is available in the Modules drop-down menu in Windows PowerShell ISE.

Format an entire folder with files

dbForge SQL Complete supports the following preset formatting profiles:

  • Collapsed
  • Commas before
  • Compact
  • Default
  • Extended
  • Indented
  • MSDN SQL
  • Right aligned
  • Stack compact

But you can create your own formatting profile and use it.

1. Run Windows PowerShell ISE as Administrator on your computer.

2. In Windows PowerShell ISE, execute the script below. The script envokes the Invoke-DevartFormatScript cmdlet that initiates the SQL Complete tool formatting functionality:

# Defining variables
$ScriptFolder = "D:\ScriptFolder\"
$FormattedFiles = "D:\FormattedFiles\"
$FormatProfile = "C:\Users\JordanSanders\AppData\Roaming\Devart\dbForge SQL Complete\FormatProfiles\CustomProfile.xml"

# Formatting scripts
Write-Host "Formatting a script folder..." -ForegroundColor Cyan
$Result = Invoke-DevartFormatScript -Source $scriptFolder -FileExtension *.sql -IncludeSubfolders -Output $FormattedFiles -Profile $FormatProfile

Parameters used in the script

Parameter Description
-Source SQL file or a folder with the files to be formatted.
-FileExtension Extension of the source folder files that will be formatted.
-IncludeSubfolders Current directory and all subdirectories in search operation.
-Output Output file or path name where formatting results will be saved.
If the parameter is not specified, the formatting results will be saved in the source file or folder.
-Profile Path to the file that contains formatting options settings.
If the parameter is not specified, default formatting options settings will be applied.

Format a single file

1. Run Windows PowerShell ISE as Administrator on your computer.

2. In Windows PowerShell ISE, execute the script below. The script envokes the Invoke-DevartFormatScript cmdlet that initiates the SQL Complete tool formatting functionality:

# Defining variables
$File = "D:\ScriptFolder\uspVendorAllInfo.sql"

# Formatting script
Write-Host "Formatting a script ..." -ForegroundColor Cyan
$Result = Invoke-DevartFormatScript -Source $File

Want to Find out More?

Overview

Overview

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

All features

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

Request a demo

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