Four minor new features of SQL 2008

There are a couple of new features of SQl Server 2008 that I’m pretty excited about that I haven’t seen geet agreat amount of attention. I thought I’d write a short article on them, so they don’t get overlooked.

  1. Variable initialisation
  2. Row constructors
  3. Multi-server queries
  4. Intellisense/syntax checking

Variable Initialisation

I’ve always been more partial to the C# way of declaring and initialising variables all at once. Now it’s possible in T-SQL too.

DECLARE @SomeVariable INT = 0, @SomeOtherVariable CHAR(5) = ‘Hello’

It’s not revolutionary, but I do like it. Anything that reduces the amount of typing and reduces the chances of bugs is worthwhile in my opinion

Row constructors

Up until now, if you wanted to insert multiple sets of values into a table, the options were multiple INSERT INTO … VALUES or a INSERT INTO … SELECT with some union alls. Neither looked very pretty.

Enter the row constructors. Need to put 5 rows into a table? Easy

INSERT INTO #SomeTempTable (ID, Letter) VALUES (1,’a’), (2,’e’),(3,’i’),(4,’o’),(5,’u’)

Less typing. Always good.

Multi-server queries

One nice feature I noticed in the Management Studio of SQL 2008 is the ability to run queries on multiple servers at once. In the registered servers window, you can right click on a server group and select New Query. The new query window that opens is then connected to all of those servers at the same time, and any query run will be run on all of them.

This isn’t so useful for developers, but it’s a fantastic time saver for admins who need to check things across multiple servers.

I’m not sure if all the servers connected to have to be SQL 2008 or not. Haven’t been able to try it yet.

Intellisense/syntax checking

Intellisense has been around in 3rd party products for a while, but it’s still nice to see it built in to the product. Also very nice is the built in syntax checking, much like in visual studio. I haven’t played much with it, so I don’t know the limitations yet. There will definitely be more written on this.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.