Integrate SQL Complete into DevOps
Last modified: March 28, 2025
dbForge SQL Complete can be integrated 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.
Prerequisites
To begin using SQL Complete in the DevOps process, ensure the following:
- PowerShell version 3.0 or later is installed.
- dbForge DevOps Automation for SQL Server and dbForge SQL Complete are installed on your computer.
- SQL files you want to format are available.
Note
PowerShell is installed on Windows 8, 8.1, and 10 by default. For other versions, download PowerShell from the official Microsoft Download Center.
To check the current version of PowerShell, open WindowsPowerShell ISE and run the
$PSVersionTable.PSVersion
command. The Major column will display the version 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.
To install 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 complete, the Devart.DbForge.DevOpsAutomation.SqlServer module will appear in the Commands > Modules list in Windows PowerShell ISE.
Note
Using the Invoke-DevartFormatScript cmdlet allows you to initiate the SQL Complete tool formatting functionality.
Use predefined formatting profiles in dbForge SQL Complete
dbForge SQL Complete supports the following predefined formatting profiles:
- Collapsed
- Commas before
- Compact
- Default
- Extended
- Indented
- MSDN SQL
- Right aligned
- Stack compact
In addition, the tool allows you to create a custom formatting profile for later use. For more information, see Profiles.
Format an entire folder with files
1. Run Windows PowerShell ISE as Administrator.
2. In Windows PowerShell ISE, run the following script:
# Defining variables
$ScriptFolder = "D:\ScriptFolder\"
$FormattedFiles = "D:\FormattedFiles\"
$FormatProfile = "C:\Users\Username\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
where:
D:\ScriptFolder\
is the path to the folder that stores the files you want to format.D:\FormattedFiles\
is the path to the folder that will store the formatted files.C:\Users\Username\AppData\Roaming\Devart\dbForge SQL Complete\FormatProfiles\CustomProfile.xml
is the default path to the file with formatting settings. To use a different location, specify the correct file path.
3. If the formatting process is successful, the result will be as follows:
Format a single file
1. Run Windows PowerShell ISE as Administrator on your computer.
2. In Windows PowerShell ISE, run the following script:
# Defining variables
$File = "D:\FormatSQL\uspGetBillOfMaterials.sql"
$FormattedFiles = "D:\FormattedFiles\formatted_uspGetBillOfMaterials.sql"
$FormatProfile = "C:\Users\Username\AppData\Roaming\Devart\dbForge SQL Complete\FormatProfiles\CustomProfile.xml"
# Formatting script
Write-Host "Formatting a script ..." -ForegroundColor Cyan
$Result = Invoke-DevartFormatScript -Source $File -FileExtension *.sql -IncludeSubfolders -Output $FormattedFiles -Profile $FormatProfile
where:
D:\FormatSQL\uspGetBillOfMaterials.sql
is the path to the file you want to format.D:\FormattedFiles\formatted_uspGetBillOfMaterials.sql
is the path to the formatted file. Note that you must specify the name of the formatted file in the script.C:\Users\Username\AppData\Roaming\Devart\dbForge SQL Complete\FormatProfiles\CustomProfile.xml
is the default path to the file with formatting settings. To use a different location, specify the correct file path.
3. If the formatting process is successful, the result will be as follows:
Parameters used in the scripts
Parameter | Description |
---|---|
-Source | Specifies the SQL file or folder containing the files to be formatted. |
-FileExtension | Defines the file extension of the files in the source folder that will be formatted. |
-IncludeSubfolders | Includes the current directory and all subdirectories in the search operation. |
-Output | Specifies the output file or folder path where the formatting results will be saved. If the parameter is not provided, results are saved in the source file or folder. |
-Profile | Specifies the path to the file with formatting settings. |
Note
If the
-Profile
parameter is not specified, the active formatting profile is used. You can check which formatting profile is active in the Options dialog under Text Editor > Formatting > Profiles.