The developers of Management Studio and, before that, Query Analyzer have made a bit of a habit of building killer features and then hiding them in the small print of Books Online. Now you may already know that SQL 2000 introduced a new way to arrange your query and result windows, but I only just found out about it. I think it’s great so, in case you blinked and missed it too, here’s how it works.
Since the dawn of time you edited your query in a full window and, when you ran it, the results covered the bottom half of the query. You could use Ctrl+R to toggle the visibility of the results. When you think about it, it’s actually pretty clumsy. These are the only combinations you can see easily:
- half of the query and half the results
- the whole query
- er, that’s it
I was so used to it that I didn’t really notice. Until somebody showed me a much better way to do it.
There’s an option under Query Results | SQL Server | Results to Grid called Display results in a separate tab. If you tick this and its sub-option the behaviour gets much more usable. When you run the query the results fill the screen. You get a second row of tabs below the row of tabs for the query windows you’ve got open. This second row has tabs for the query, results and messages and (optionally) things like the query plan. It looks like this:
You can tab backwards and forwards between these tabs using F6 and Shift+F6 respectively. You can quickly toggle between the query and results and you can see both of them properly.
You really should try this. Your muscle memory will protest but stick with it. I think you’ll find it was worth it.
If you highlight the name of an object in a query window in SQL Management Studio and press Alt+F1 you instantly get a set of results showing almost everything you could want to know about the object: columns, parameters, datatypes, constraints, indexes, storage details. This works on your own tables etc. not just system objects. Forget scrolling around in the Object Explorer.
What’s actually happening is that the system stored procedure sp_help is being executed (with the highlighted text as the parameter value) because sp_help is bound to the keyboard shortcut Alt+F1. You can see and customise these query shortcuts in the Environment / Keyboard part of the Options dialogue (menu Tools / Options).
Really obvious once you know it’s there, but it hasn’t been very well publicised!