Many automatically opened SQL tabs in SQL Server Management Studio have names like SQLQuery1.sql, SQLQuery2.sql etc:
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:
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
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.