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:
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.
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.
dbForge SQL Complete supports the following preset formatting profiles:
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
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. |
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