Changing file name extensions in Windows Mobile

Now, of course you can do this by connecting your mobile to your PC and just finding the file – but sometimes you don't have your laptop with you, right?

Today I came across a utility which lets me do this – it's PocketPlus from Spb. Definitely worth checking out I think. Spb also have a very nice Mobile Shell, which seems to rival PointUI (which I also think is very good). PointUI wins out for me at the moment though, because I'm having to use my old Windows Mobile 2003 device. Also, it seems to have been written by Aussies, which can't be bad.

Dynamic ordering with T-SQL

This is an oldie, but a goodie. I was talking to Dave Gardiner about a question he had recently, the question of how to dynamically sort the results of a T-SQL query.

He was thinking of something like this:

–Not so useful – only works in a stored procedure
IF (@order = 'Column1')
    SELECT * from Table1 ORDER BY Column1
ELSE IF (@order = 'Column2')
    SELECT * from Table1 ORDER BY Column2

And one of the suggestions in his comments was to use the CASE statement:

–Not bad, but only works if the types are compatible
FROM Table1
   CASE WHEN @order = 'Column1' THEN Column1 ELSE Column2 END

This isn't bad, but if Column1 and Column2 are different types (well, incompatible types), you get an error when the ELSE clause is used.

A better solution is to remember that CASE gives NULL if there nothing is satisfied:

FROM Table1
   CASE WHEN @order = 'Column1' THEN Column1 END,
   CASE WHEN @order = 'Column2' THEN Column2 END

This way, it's either ordered by "Column1, NULL" or by "NULL, Column2". Both times, it's the order we want, and we're doing it in a single query.