...into @temp values ('B',2010,1,2,7)
insert into @temp values ('C',2010,1,2,7)
insert into @temp values ('A',2010,1,3,9)
;with mycte as (
select *,
CAST(CAST(year AS VARCHAR(4))+
RIGHT('0'+CAST(month AS VARCHAR(2)),2)+
RIGHT('0'+CAST(day AS VARCHAR(2)), 2) AS DATETIME) as tdate
from @temp)...