# 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
# Tuesday, August 24, 2004

Your natural dimension primary key maybe too large to use in a data-mart with hundreds of millions of rows so you might need to create a smaller alternate key. Sometimes it's not always best to use IDENTITY columns.

Imagine the case where you are importing data from an external system. The usual method to add the correct foreign keys is to either create a lookup (in DTS) which can be very slow, or try and join the imported data to your dimension table and extract the dimension key (which is also pretty slow). I've used a date lookup here as an example (time of day is not used):

update dbo.ImportedData
set DateID = d.DateID
from dbo.ImportedData t join dbo.Dates d
    on d.Date = cast(floor(cast(t.Date as float)) as smalldatetime)

For dimensions like this it maybe much more efficient to create keys using a calculation performed on the common fields. For example, the number of days since a point in time:

update dbo.ImportedData
set DateID = datediff(day, '2000-01-01', Date)
from dbo.ImportedData

This avoids any sort of join and, in fact, could be performed on the data stream as it is loaded into the database. Also, if you use a smallint for the key then you get a 50% saving from the original smalldatetime type and are still able to use dates past 2175.

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

OK, it crashes a bit because it's beta software. But at least it has this:

Auto Recovery Dialog

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Tuesday, August 24, 2004 4:39:06 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback

In order to optimise queries fully in previous versions of SQL Server you might have had to create a covering index by adding all the select and where columns to the index definition. This enabled an index to completely satisfy a query and avoid a bookmark lookup on the underlying table.

In Yukon there is a new keyword on the CREATE INDEX syntax - INCLUDE. This allows you to store additional non-key columns with the index but avoid the cost of them being in the actual non-leaf index structures. So for example:

create index IX_Dates_Date on dbo.Dates(Date)
include (
    Year, Month, Day,
    MonthName, DayOfWeekName, WeekOfYear
)

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Tuesday, August 24, 2004 1:54:09 PM (GMT Daylight Time, UTC+01:00)  #    Comments [1] Trackback
# Monday, August 23, 2004

They only seem to care because we, as software developers, make them play the requirements game. In reality, the only thing that that matters is how the final product matches up to their expectations. The big problem is that you can't capture them in a document to use as the blueprint for development. There are some things you can to ensure your customer is happy with the end result:

  1. Write a short "Vision" document describing the key features to get everyone on the same page early on
  2. Program by feature to produce functionality early, don't spend too much time on infrastructure
  3. When you've completed a feature, show it to the customer and get feedback
  4. Allow the customer to change their minds

These points will only work when both you and the customer share the project risk; either with fixed rates/variable time or fixed time/variable functionality.

If it's a fixed price/fixed functionality contract then you'd better start writing those requirements...

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Monday, August 23, 2004 7:06:50 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
# Wednesday, August 18, 2004
There is an excellent article in this months MSDN Magazine entitled "Streamline Your Database Setup Process with a Custom Installer". We do something similar in our own product, but nowhere near as complete as this. It covers version checking, upgrades, patches, extended stored procedures and bulk loading of data.
by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Wednesday, August 18, 2004 1:12:20 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback