Compare objects with formatting differences

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.

Activate Format Database Object Script in Text Compare

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.

Practical example

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.

Deactivated - Format Database Object Script 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.

Activated - Format Database Object Script in Text Compare

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.

Want to Find out More?

Overview

Overview

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

All features

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

Request a demo

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