dbForge Schema Compare for SQL Server detects and displays differences in both object definitions and their scripts formatting.
When comparing database objects, such as procedures, views, triggers, and functions, dbForge Schema Compare automatically applies the active formatting profile rules to the SQL code being compared. This formatting only impacts how those scripts are displayed in Text Compare and does not alter the objects.
To prevent Text Compare from displaying differences in formatting, ensure the Format Database Object Script in Text Compare option is activated. This option turns on the Format Database Object Script button on the Text Compare toolbar, which can be turned off if necessary.
Note
Regardless of whether the Format Database Object Script is enabled, if the objects on the source and target differ only in formatting, they will be displayed in the Identical section of the comparison document and will not be included in the deployment script.
To activate the Format Database Object Script in Text Compare option:
1. On the ribbon, select Tools > Options.
2. In the dialog that opens, navigate to Schema Comparison > General. The Format Database Object Script in Text Compare checkbox will be selected. If not, select the checkbox and click OK to save the changes.
Note
Activating the Format Database Object Script option affects only the subsequent comparison, not the current one.
Let’s illustrate the comparison of database objects with formatting differences.
There are two procedures - one for the production database and one for the development database. They differ in their definitions due to a different column alias used in the SELECT statement and have different formatting.
Development
GO
CREATE PROCEDURE dbo.AddNumbers1 (@num1 INT, @num2 INT)
AS
BEGIN
DECLARE @sum INT
SET @sum = @num1 + @num2
SELECT @num1,
@num2;
SELECT @sum AS 'Sum'
END
GO
Production
GO
CREATE PROCEDURE dbo.AddNumbers1 (@num1 INT, @num2 INT)
AS
BEGIN
DECLARE @sum INT
SET @sum = @num1 + @num2
SELECT @num1, @num2;
SELECT @sum AS 'Summa'
END
GO
Now, run the schema comparison.
The Schema Comparison document opens, showing the results. The procedure appears in the Different section of the document due to the different DDLs they have.
When you turn off Format Database Object Script on the Text Compare toolbar, dbForge Schema Compare detects two differences between the source and target: one resulting from formatting and the other from a change in the logic of the procedure’s code. All changes are highlighted in Text Compare.
Now, we turn on Format Database Object Script to make Schema Compare ignore differences in formatting. As you can see, the procedure code undergoes reformatting on both the source and target, and Text Compare now only highlights the difference in logic.
The Format Database Object Script in Text Compare option instructs dbForge Schema Compare to exclusively display logical differences in the scripts of database objects and to ignore any formatting discrepancies.