Home Forums SQL Server 2008 T-SQL (SS2K8) Username increment by 1 if already exists in table RE: Username increment by 1 if already exists in table

  • crmitchell - Tuesday, January 17, 2017 6:25 AM

    MMartin1 - Wednesday, November 9, 2016 11:59 AM

    What is the rule if you have three people named Bo Derek, or four people named Joe Smith? In the prior code run I see that the last one gets missed. That is why I am not a fan of "intelligent keys" and would prefer to simply use some numeric identifyer for the person. Is it that you are wanting to assign email addresses ?

    They don't even all need to be the same

    John Smith
    Joseph Smith
    Jo Smith

    will have a problem with the third name (although a different order would still work)

    There are relatively simple ways to get around this situation, but the OP never specified how he wanted to handle them, so I didn't incorporate them into my solution.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA