Change the color of Automatic Matching of Syntax Pairs in SQL Server Management Studio

Automatic matching of syntax pairs is a feature of SQL Server Management Studio which gives you immediate feedback on whether syntax elements that must be coded in pairs are correctly paired when you write any query in query editor. It is also known as delimiter matching.




Whenever, you cursor in one of the delimiter in a pair, you can use keyboard shortcut CTRL+] to jump to the matching delimiter. Using this you can quickly identify any missing pair of delimiter.

When you go over the delimiter and the one that you have selected it’s pair turn gray, in this way query editor lets you visually identify code blocks and check for mismatched pairs of delimiter. If you do not find any matching pair of any delimiter that means something wrong.

Automatic delimiter matching identifies the following sets of delimiters:

Lead Delimiter     Closing Delimiter
(                             )
BEGIN                   END
BEGIN TRY            END TRY
BEGIN CATCH       END CATCH

Lets see it in action, Go to SQL Server Management Studio, open a query editor window.

Now write some piece of code that uses some parentheses as shown below.

SELECT Number
FROM
( SELECT 1 AS Number
   UNION
 SELECT 2 AS Number
  UNION
SELECT 3 AS Number
) TBL

Sometime it’s hard to see the parentheses, when you have a large piece of T-SQL code as gray color is very light and less visible on white query editor screen.

In this case, If you want to change the gray color to something else. Then you can change the color from Tools menu in SQL Server Management.

Go to Tools then Select Options..

Next you will see, a options dialog box opens.

Now under the Environment, click on Fonts and Colors, then select Brace Matching (Rectangle).

You will see that the default color is gray for Item background.

Now you can select any color for Item Background.

Lets change the color to Yellow, and click on OK button.

After clicking on OK button, Lets go back to query editor.

Now, just go over the first opening braces “(“, you will see that the matching pairs (including opening and closing) turn in Yellow.

You will see, that the yellow color is more highlighted in comparison to gray.

Lets take one more example using TRY.. CATCH block.

For a BEGIN CATCH.. END CATCH pair when you type a BEGIN CATCH first followed by END CATCH, you will see a highlighting turns on when you type the last letter that is “H” in END CATCH.

You will notice that yellow color is more highlights than gray color.

BEGIN TRY
   SELECT Number
   FROM
      (  SELECT 1 AS Number
            UNION
        SELECT 2 AS Number
           UNION
        SELECT 3 AS Number
        ) TBL
END TRY
BEGIN CATCH

SELECT 'Error'

END CATCH

Also Read..

Get Dark theme in SQL Server Management studio

Get the detailed information of all datatypes in SQL Server

Deal with SQL Server Verbose Truncation Warnings

SQL Basics TutorialSQL Advance TutorialSSRSInterview Q & A
SQL Create tableSQL Server Stored ProcedureCreate a New SSRS Project List Of SQL Server basics to Advance Level Interview Q & A
SQL ALTER TABLESQL Server MergeCreate a Shared Data Source in SSRSSQL Server Question & Answer Quiz
SQL DropSQL Server PivotCreate a SSRS Tabular Report / Detail Report
..... More.... More....More
Power BI TutorialAzure TutorialPython TutorialSQL Server Tips & Tricks
Download and Install Power BI DesktopCreate an Azure storage accountLearn Python & ML Step by stepEnable Dark theme in SQL Server Management studio
Connect Power BI to SQL ServerUpload files to Azure storage containerSQL Server Template Explorer
Create Report ToolTip Pages in Power BICreate Azure SQL Database ServerDisplaying line numbers in Query Editor Window
....More....More....More




 479 total views,  5 views today

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.