with samp as( select isnull(convert(int,SUBSTRING(ID,4,1)),0)as ID from TableFacility ) SELECT 'ACF'+convert(varchar,MAX(ID)) as MaxID FROM samp
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)