hi,What is the final output?;with aCTEAS( select 'XAP0000100' as Duplicates union all select 'XAP0000100-1' union all select 'XAP0000100-2' union all select 'XAP0000101' union all select 'XAP0000101-1' union all select 'XAP0000102' union all select 'XAP0000103' union all select 'XAP0000103-1' union all select 'XAP0000103-2' union all select 'XAP0000103-3'),newCTEAS ( select duplicates ,case when charIndex('-',duplicates) >0 then left(duplicates,charIndex('-',duplicates)-1) else duplicates end as newValue from aCTE) select * from newCTE
duplicates newValueXAP0000100 XAP0000100XAP0000100-1 XAP0000100XAP0000100-2 XAP0000100XAP0000101 XAP0000101XAP0000101-1 XAP0000101XAP0000102 XAP0000102XAP0000103 XAP0000103XAP0000103-1 XAP0000103XAP0000103-2 XAP0000103XAP0000103-3 XAP0000103
SsabinWeb MCP