Thursday, October 11, 2007

T-SQL little secrets (part 1)

Today I enriched myself with a new piece of knowledge.
Here it is:

The return type from a CASE expression is always the one and the
same, no matter which WHEN branch that is selected. The datatype
is determined by SQL Server's datatype precendence, which says that
when two types meet, the type with lower precendence is converted
to the type with higher precendence.
Basically, if you have something like this:
Select * from Users
ORDER BY
case upper(@OrderBy)
when 'USERNAME' then Username
when 'LASTNAME' then LastName
when 'FIRSTNAME' then FirstName
when 'BIRTHDATE' then BirthDate
else LastName
end
and the columns have different data types, forget it. You can't. You have to use a case for each data type:
Select * from UsersT
ORDER BY
case upper(@OrderBy)
when 'USERNAME' then Username
when 'LASTNAME' then LastName
when 'FIRSTNAME' then FirstName
else LastName
end,
case upper(@OrderBy)
when 'BIRTHDATE' then BirthDate
end

Read the complete message here.

Thursday, October 4, 2007

Software Patents are evil (and stupid too)

If you already don't know, Microsoft will grant all of us the privilege to pass our humble eyes across some of the .Net source code. Hurray.
But for americans, that can be a problem...
Read this. Very funny and entertaining, if you live on the right side of the Atlantic Ocean.
Thank god we don't have software patents...




PS: The right side of the ocean is the one without the stupid president.

No coding allowed here!

Long time no see!! As you may guess, I'm a little short on time, not even to write in this blog... let's hope I can change the trend.

For starters, here is a very nice article about how computers/devices are less programmable. Less programmable, you ask?
Yes. From the point of view of the author, it's harder to develop now than it was 20 years ago. Remember the ZX Spectrum? Your interface was a BASIC interpreter...
He has a good point, especially for the new devices.