Export (0) Print
Expand All

Using Transact-SQL Delimiter Matching

Visual Studio 2010

Transact-SQL delimiter matching gives you immediate feedback on whether syntax elements that must be coded in pairs are correctly paired. The Transact-SQL editor matches the delimiters that identify the boundaries of code blocks. The matching is done in the following way:

  • The editor highlights both delimiters in a pair when you finish typing the second delimiter in the pair.

Automatic delimiter matching recognizes the following sets of delimiters:

Lead Delimiter

Closing Delimiter

(

)

BEGIN

END

BEGIN TRY

END TRY

BEGIN CATCH

END CATCH

Automatic delimiter matching does not recognize the delimiters for bracketed identifiers ([ObjectName]), or quoted identifiers ("ObjectName"). Pair matching does not match the single quotation delimiters for string literals ('string') because color coding already gives a visual indication of whether the string has been delimited.

Delimiter matching highlights both the lead and closing element of a pair of delimiters. This lets you visually identify code blocks and check for mismatched pairs of delimiters.

Delimiters are highlighted when you type the final letter that completes the pair. For example, for a BEGIN END pair where you type BEGIN first followed by END, highlighting turns on when you type the final letter in END. You do not have to type the lead delimiter followed by the closing delimiter to turn on highlighting. If you type END first, then scroll back up the script and type BEGIN, highlighting is turned on when you type the final letter in BEGIN. The final letter typed does not have to be the end letter in the delimiter. For example, you could misspell BEGIN as BEIN, when you insert the final G the BEGIN END pair is highlighted.

The delimiter pair remains highlighted until you move the cursor. The highlighting is turned off when the cursor is moved, even if the new cursor position remains in the same delimiter. You can turn the highlighting back on by deleting and retyping any letter in either member of the pair.

Show:
© 2014 Microsoft