Tabs Studio Blog (organizing Visual Studio document tabs)

March 11, 2014

Add an SQL query description to the SSMS tab name with the SQLComment add-in

Filed under: Uncategorized — Tags: , — Sergey Vlasov @ 9:35 pm

Many automatically opened SQL tabs in SQL Server Management Studio have names like SQLQuery1.sql, SQLQuery2.sql etc:

SQLQuery tabs in SSMS 2012

SQLQuery tabs in SSMS 2012

To better distinguish such tabs I’ve created the SQLComment add-in that can add a comment from the query body to the tab name:

Tabs with comments in SSMS 2012

Tabs with comments in SSMS 2012

You can chose any comment format and configure SQLComment to extract it using a .NET regular expression. For example, the default regex
StoredProcedure \[dbo\]\.\[(?<M>\w+)\] extracts the procedure name (AddEvent) to the M named group from the following code:

USE [ReportServer]
GO
/****** Object:  StoredProcedure [dbo].[AddEvent]    Script Date: 3/11/2014 8:29:10 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SQLComment options

SQLComment options

To extract description from a comment like ––– provides details on investors you can use the regex ^––– (?<M>.+)$. To support several formats you can combine regexes with ‘|’ like ^––– (?<M>.+)$|StoredProcedure \[dbo\]\.\[(?<M>\w+)\]. You can use several separate M groups (line Name and Ext in standard tab grouping), the resulting string will be concatenated from all captures. Only tabs starting with SQLQueryNN.sql are considered for commenting.

Download link: SQLComment v1.0.0.

Update (March 20): Added commenting support for grouped tabs SQLComment v1.0.1.

Update (October 23): Added the “Set SQL comment…” tab context menu command for temporary comments. Added more customization for displaying comments. SQLComment v1.0.4.

Blog at WordPress.com.

%d bloggers like this: