Maybe I'm missing the real issue here, but I don't understand the use of the "while @array_value <> '0'" (or the line above if for that matter...is something missing?). Would this work? Replace the while @array_value... line with an IF statement:CREATE procedure sp_ZipCode_Count( @Array varchar(1000),@Separator char(1) ) ASset nocount on-- @Array is the array we wish to parse-- @Separator is the separator charactor such as a commadeclare @separator_position int -- This is used to locate each separator characterdeclare @array_value varchar(5) -- this holds each array value as it is returned-- For my loop to work I need an extra separator at the end. I always look to the-- left of the separator character for each array valueset @array = @Array + @Separator-- Loop through the string searching for separator characterswhile patindex('%' + @separator + '%' , @array) <> 0 begin-- patindex matches the a pattern against a stringselect @separator_position = patindex('%' + @separator + '%' , @array)select @array_value = left(@array, @separator_position - 1)-- This is where you process the values passed.-- Replace this select statement with your processing-- @array_value holds the value of this element of the arrayselect Array_Value = @array_value -- ???IF len(@array_value) > 0 begin SELECT count(*) FROM customer WHERE zip in (@array_value)end-- This replaces what we just processed with and empty stringselect @array = stuff(@array, 1, @separator_position, '')--endendset nocount offGO