username upper case lower case how to fix

  • there is a field userid, firstname and last name which is allowing such userids Allowing upper case and Lowercase  , How to fix it so it does not allow upper case/lower case and considers it duplicate?

     

    userid firstname lastname

    aina aina aina

    Aina Aina Aelson

    Thanks in Advance

     

     

  • That's somewhat confusing.  Do you want to not allow mixed case at all?  Or do you just want to prevent a duplicate from being inserted, basically ignoring case in determining dup?

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • prevent duplicates, ignoring case would be better

  • You've got some choices, some more annoying than others:

    (1) Use an INSERT trigger to check for dups and cancel if a dup would be created.

    (2) Create additional columns that are case sensitive and build a UNIQUE index on those columns.

    (3) Change the original columns to case sensitive and then build a UNIQUE index on the columns.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • What collation are you using for these columns ?

    If you are actually using case sensitive collations:

    How about using lower(userid) , lower(name) and lower(firstname) with the insert statement

    or have a persisted computed column performing the concat using these functions and put a unique index on that one.

    -- add this computed column
    , [userid_name_firstname] AS concat(lower(userid), lower(name),lower(firstname)) PERSISTED

    ...

    create unique index x_userid_name_firstname on yourschema.yourtable( userid_name_firstname )

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply