# Thursday, September 09, 2004

The Photo Gallery is out of order at the moment. I seem to be having some nGallery issues with it. Thanks to everyone who mailed me to let me know.

[Edit: Actually, it's up and down like a whore's drawers so try your luck with it...]

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Thursday, September 09, 2004 4:10:44 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
# Wednesday, September 08, 2004

I was in a customer data centre today. It's quite impressive seeing all the racks of servers they have. The customer in question is one of the UK's leading banks and the physical security of the place is amazing:

  • No company name on the building - you have to know it's the right place
  • Double layer prison style fencing with security cameras
  • Steel gate that opens for your car when buzz and speak to security
  • You have to pass though an outer door (operated by security again) before signing in and picking up your pass
  • To sign in you have to have a prearranged visit organised 72 hours in advance
  • Then an inner door (security personnel operated)
  • You are now in the building but only have access to the canteen and toilets
  • You get collected by a member of staff and go to the data operations gallery to pickup a second pass (green level -> limited access)
  • Finally with this second pass you get access to the room and rack where your servers are

Once inside the server room you understand the reason for all the security. It's full of mainframes and storage systems where the bank keeps their data. Very impressive to see and kind of makes our two 2U servers look a bit small.

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Wednesday, September 08, 2004 9:02:44 PM (GMT Daylight Time, UTC+01:00)  #    Comments [1] Trackback
# Friday, September 03, 2004

One of the nice things about System.String is that two variables having the same contents will point to the same object once they have been interned. So you have the following:

string s1 = "abcdef";
string s2 = "abcdef";

object o1 = string.Intern(s1);
object o2 = string.Intern(s2);

Debug.Assert(o1 == o2);

This can be put to good use when you want to use caching... If the non-cache lookup is expensive, say a database call, you want to ensure that the lookup operation will only happen once in the presence of multiple threads. The lock(cache) keyword is ideal but not very granular. An alternative is the lock the cache key:

public string GetFromCacheOrLookup(string key)
{
    lock (string.Intern(key))
    {
        string result = (string)cache[key];

        if (result == null)
        {
            result = LookupFromDatabase(key);
            cache[key] = result;
        }

        return result;
    }
}

This method allows multiple threads to perform the expensive lookup as long as the key is different; if not then they wait for the initial lookup to complete before continuing.

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Friday, September 03, 2004 1:07:43 PM (GMT Daylight Time, UTC+01:00)  #    Comments [3] Trackback
# Thursday, September 02, 2004

I couldn't resist this when I saw it in the shop... Maybe I can use it as a stand in at meetings? But then again I feel the need to keep it in its box as it looks kind of geekier there... I took a few more pictures too.

If you squint hard I reckon it looks a little like like Robert Scoble. In fact, if you look at the notebook that comes with it the task bar is unmistakably Windows but there was no tablet pen supplied so I guess it can't be him after all...

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Thursday, September 02, 2004 3:27:35 PM (GMT Daylight Time, UTC+01:00)  #    Comments [2] Trackback
# Wednesday, September 01, 2004

I have 5 Gmail invites to give away... I'll give them to the first 5 people to leave a comment telling me why they read this blog and what content they want to see in the future.

[Edit: They keep giving me more so check back here to see if I have any spares. Current count: 0... All gone for the moment, but if you add your name then I'll send you one as soon as I get some more.]

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Wednesday, September 01, 2004 10:54:19 AM (GMT Daylight Time, UTC+01:00)  #    Comments [5] Trackback
# Tuesday, August 31, 2004

...that you can swap between Amazon in the US and UK by changing the .com to .co.uk as the URL query string will return the same book regardless of the site. I guess it's not rocket science when you think about it, but useful all the same.

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Tuesday, August 31, 2004 5:05:29 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Tuesday, August 31, 2004 11:25:44 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
# Sunday, August 29, 2004

OUTPUT Clause

This one gives you access to the inserted and deleted tables in normal SQL so you can write statements like:

DECLARE @changes TABLE (
    ProjectId int,
    Name nvarchar(max),
    Description nvarchar(max)
);

update dbo.Projects
set Billable = 1
output
    inserted.ProjectId,
    inserted.Name,
    inserted.Description
into @changes
where Billable = 0

WRITE Clause

Allows more efficient updates of varchar(max), nvarchar(max) and varbinary(max) columns. For example:

declare @update_text nvarchar(max)
set @update_text = ' ... this is added to the end'

update dbo.Projects
set    Description.write(@update_text, null, len(@update_text))
where  Name = 'Timesheet'

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Sunday, August 29, 2004 7:05:47 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
# Saturday, August 28, 2004

A Short History of Nearly EverythingThe incomparable Bill Bryson travels through time and space to introduce us to the world, the universe and everything. -- Amazon

I have never read anything by Bill Bryson before as I'm not really into his usual genre of travel writing but I was given this by a friend. In short, it's a great book - I was hooked by the end of the introduction where he describes his early experiences with a textbook containing a cut-away of the earth illustrating the earth's interior. He asks "How did they know that?". A question which resonates from my own school years, where teachers would often avoid the question or provide some unconvincing answer. The book promised to provide some real answers.

As for the "nearly everything" description, he is not wrong. The book covers some five hundred years of scientific history and touches on subjects of cosmology, maths, physics, chemistry, geology, vulcanolgy and biology. We learn how to build a universe, how to measure the size of the earth, what the inside of an atom is like, how mountains are created (and destroyed), the precarious nature of life and how we came to be.

The whole text is littered with little tidbits of curiosity; like the person who really discovered something as opposed to the person given the credit and the back story to each scientific breakthrough. He must have expended a huge amount of energy to get all this in. All of this is told in a witty style that makes compelling reading.

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Saturday, August 28, 2004 2:57:01 PM (GMT Daylight Time, UTC+01:00)  #    Comments [1] Trackback

Microsoft have adjusted their goals and dates for Windows Longhorn. Primarily by relegating WinFS to an add-on that will be shipped later; but also committing to ship Indigo and Avalon on XP and Windows 2003 systems. There is no mention of the user experience (Aero) though. More details can be found here:

[Edit: Jim Allchin, the Group Vice President for Platforms at Microsoft, is on video at Channel 9 explaining the details.]

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Saturday, August 28, 2004 11:49:10 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
You can sign up for beta-place access if you have found any bugs in SQL Server 2005. Details are at http://msdn.microsoft.com/sql/bugs/.
by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Saturday, August 28, 2004 11:06:24 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback

Aaron Bertrand has started collecting content for a SQL Server 2005 FAQ. There is some useful stuff in there but needs more content so here you go Aaron.

Why do new query windows use the master database?

This behaviour is different from Query Analyzer and can often cause you to execute scripts in the wrong database. This is especially unproductive as there is no select multiple in Object Explorer to clean up the damage quickly.

In actual fact the old Query Analyzer behaviour is still there, just under a different button. You need to select New Query with Current Connection  which is just to the left of the database selection list in the SQL Editor tool bar. Alternatively, CTRL-Q (Standard Keyboard Scheme) or CTRL-N (SQL Server 2000 Scheme) will do the same.

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Saturday, August 28, 2004 10:59:41 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback