Category Archives: SQL Management Studio

Intellisense: the ghost in the machine

Intellisense really does have a mind of its own. I installed SQL 2008 R2 on my dev machine side by side with my existing 2005 installation and Intellisense worked fine. Granted it has some really annoying habits. (Dude, I typed a valid keyword followed by a space – why did you change it to something completely different?) But on the whole I like it. Then, about 3 weeks ago, I wiped the machine and did a clean R2 instal. Could I get Intellisense to work? Could I f***! I scoured the web and followed a whole load of magic voodoo rituals but nothing worked. I was resigned to trying a repair and/or a re-instal when I had nothing urgent to do. (Ha!) But this morning, out of the blue, it just started working. I guess one of the Windows updates mended something. Who knows?
So if your Intellisense doesn’t work, just keep calm and carry on. It will come back one day all by itself. Probably.
Advertisements

A better way to arrange your query windows

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.

Quick Info About an Object

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!