Solved

How to label queries?

Posted on 2011-09-23
7
331 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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Select * from 6 41
PERFORMANCE OF SQL QUERY 13 72
Record open by another user 6 57
Find data in a column which is not in  a date format 29 30
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 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