Solved

How to label queries?

Posted on 2011-09-23
7
333 Views
Last Modified: 2012-05-12
In Management Studio results tab, how do I give each query a header or label?  When a few queries are printing their results, it can be confusing to know which query is which.
0
Comment
Question by:brettr
7 Comments
 
LVL 51

Expert Comment

by:HainKurt
ID: 36589192
SSMS is really stupid... you cannot rename TABS, and after a while you cannot find which one is what and which server it is running on... and the expand icon does not help either if you have, say more than 6 open tabs... MS should update this tool, they can chack how Quest - TOAD implemented this...
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 36589668
The only way to do it really is to save the SQL script you are running.  I use the MDI interace as opposed to Tabbed and makes it easy to go into the Windows list and see what is running, where, and what it's called.
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 36589700
saving is not an option for me :) when I work wit SQL I always create new queries test something and close re-open new windows... I dont want to save all my garbage queries :) but if we save them as "Setup" for example, tab name shows "c:\path_to_file\Setup.sql - DBNAME" :) maybe this option is better than nothing...
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

Author Comment

by:brettr
ID: 36589887
I think you guys are talking about something completely different.  You keep talking about TABS.  I'm in one window with a corresponding results tab.  That tab is fine and no concern.  In the results tab, I have 5 result sets.  I cannot tell which result set goes to which query.  I just want some type of name to correspond to each result set so I can point it back to the query that generated it.
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 36589890
Trust me.  I know.  My current session of SSMS is at #163 for new query windows created.  I'm just offering a suggestion which I have found useful for queries that I am bouncing back and forth between.  Quick open/close queries don't need to be named.  It's the ones that you are working on, tweaking, running, coming back to.  Have you ever have SSMS crash?  I have, and lost several queries in progress that the recovery couldn't get.  That's why for anything I'm going to keep around for longer than a minute or two I save it.
0
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 250 total points
ID: 36589916
Ahh..  Yeah, we're talking about something completely different.

For that, if just need a quick label, I do a select above the real select to describe it.

Ex.

Select 'Next result is result of A join B'
select * from A inner join B on a.some1 = b.some1

When working with temp tables in debugging mode I have a different approach.


select '#Test' as '#Test',* from #Test



0
 
LVL 9

Assisted Solution

by:anillucky31
anillucky31 earned 250 total points
ID: 36597202
There is no direct way to do it. You can modify your queries. You can add custom Column in each of your query and can give it static value and column name.

For Example

select 'Query1' as Query1, col1, col2 from yourtable
select 'Query2' as Query2, col1, col2 from yourtable
.
...

..
Like this when you will see your result in result pane you can identify by first column from which query this result has come.


I hope this will help you.
 
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question