Fix export SQL to include full range