Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to label queries?

Posted on 2011-09-23
7
Medium Priority
?
342 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 59

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 59

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
How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

 

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 1000 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 1000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

704 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