SQLServer2008 在where條件中使用CASE WHEN
(case when LEN(A.startMonth)=1 and A.startMonth!=0 then cast((CAST(startYear as varchar(4))+'0'+cast(A.startMonth as varchar(1))) as date)
when LEN(A.startMonth)=2 then cast(CAST(startYear as varchar(4))+cast(A.startMonth as varchar(2)) as date) end) <=cast(@condition as date)