with T as (
SELECT [idCard],
(right(left([idCard],10),4)+'-'+right(left([idCard],12),2)+'-'+right(left([idCard],14),2)) 'Birthday',
(case when (left(right([idCard],2),1) % 2 = 0) then '女' else '男' end ) Sex FROM [TestIDCard]
where len([idCard])=18
union all
SELECT [idCard],
('19'+right(left([idCard],8),2)+'-'+right(left([idCard],10),2)+'-'+right(left([idCard],12),2)) 'Birthday',
(case when (right([idCard],1) % 2 = 0) then '女' else '男' end ) Sex FROM [TestIDCard]
where len([idCard])=15
)