All of the parts of a CASE must return the same data type - otherwise what will the type of the column be?So you cannot have one THEN return a varchar and another THEN return an int. You could rewrite it like this (note - I used cast because it is ANSI standard, you could do it with convert too).DECLARE @CaseNo VARCHAR(10)SET @CaseNo='xyz'SELECT CASE WHEN CHARINDEX('.',@CaseNo)=0 THEN @CaseNo ELSE cast(cast(parseName(@CaseNo,2) as int) as varchar(10)) END as Second,CASE WHEN CHARINDEX('.',@CaseNo)=0 THEN @CaseNo ELSE cast(cast(parseName(@CaseNo,1) as int) as varchar(10)) END as FIRST