• I should remember implicit cast using CASE clause.

    Good question. I refreshed implicit cast.

    In sql2000, it gives error also with SET @sortby='Date1'. (Syntax error converting datetime from character string.), not in sql2005.