• Stephane

    OK, that clears up the IP conversion algorithm.  I still don't think that your sample data from tbl_ip2countries and from #regions tally up with each other, but let's not worry about that for now.

    Try this:

    update r

    set countryId = c.countryId

    from #regions r join tbl_ip2countries c

    on r.ipFloat between c.ipFrom and c.ipTo

    Not sure how it would perform, but much better than a cursor, I should think.  You could experiment with using >= and <= operators instead of the BETWEEN function to see if that goes any faster.

    John