# Friday, August 31, 2007
Friday, August 31, 2007 12:36:35 PM (GMT Daylight Time, UTC+01:00) ( .Net General | Database )
It's fair enough that SQL won't accept a parameterised query like below, because it cannot verify that the parameter is referring to a valid column.
select * from table order by @OrderBy
the work around then is to use a case statement like so:
select * from table order by case 
when @OrderBy = 'Column1' then Column1
when @OrderBy = 'Column2' then Column2
end
but i ran into a problem with this approach, where sql raises an error if the datatypes of the columns are not all the same, e.g. you may want to sort by an Int or NVarChar column.  the datatype precedence rules applied to the case statement are well explained in this post on google groups.  the solution posted by Erland Sommarskog is to have a separate case statement for each clause.  so the more robust approach is like so:
select * from table order by 
case when @OrderBy = 'Column1' then Column1 end,
case when @OrderBy = 'Column2' then Column2 end



Comments [0] | | # 
# Wednesday, August 29, 2007
Wednesday, August 29, 2007 1:34:31 PM (GMT Daylight Time, UTC+01:00) ( Asp.Net )
i couldn't figure out why IE was giving me an 'invalid argument' for using code like:
window.open("http://whatever", "1234321-ABCDE-1234231");
the problem is that IE only accepts alphanumeric and underscore characters for the second parameter (window name), so the hyphens were causing problems.  just trim them out and it will work fine.

Comments [1] | | # 
# Saturday, August 25, 2007
Saturday, August 25, 2007 7:59:18 PM (GMT Daylight Time, UTC+01:00) ( Outdoors )
i'm just back from an 8 day hiking trip to the dingle peninsula in co. kerry (ireland).  it was really amazing, i kept a short (and very amateur) video blog (below).  if you're doing the trip, i would recommend getting the Ordnance Survey maps 70 and 71, and follow the map route rather than the hillwalker signposts. in some places the signs were diverted to what seemed like an easier/more boring walk.  i camped in a small 2 man Vango tent, the ultralite 200 which was very light and quick to pitch, which is great when you are hiking on your own and you might be tired and cold by the time you stop walking for the day and pitch the tent.  a word of advice on this tent would be to face it into the wind so that you get a good airflow through the vents, if it gets too cold you can always throw on more clothes or close up the vents a little, but the worst thing is getting too much condensation inside and then stuff gets damp.  the tent was really great though, and i had the vango ultralite 100 sleeping bag to match, which was not the warmest but very adequate and most importantly very light.  the trail was easy enough to find your way around, crossing over brandon/masatiompan mountain was the only difficult part, especially when the mist came down, but there were signposts every 10 or 20 metres to guide you down the mountain.  the only time i needed a compass was to get out of tralee town!

more info on the trail is at http://www.dingleway.net/
Day 1:

Day 2:

Day 4:

Day 6:

Day 7:
Comments [1] | | #