You can use LEFT function without regard to how long the string is. If the string happens to be shorter than the length parameter of the LEFT function, it will simply return the entire string.DECLARE @x VARCHAR(9);
SET @x = 'ABCDEDGHK';
SELECT LEFT(@x,5);
--- returns 'ABCDE'
SET @x = 'AB';
SELECT LEFT(@x,5);
--- returns 'AB'
If your zip happens to be null and you want to handle that, you can use the COALESCE on top of that. For example,
SELECT COALESCE(LEFT(@x,5),' None ');