February 27, 2024 at 6:24 pm
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
February 27, 2024 at 6:53 pm
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".
February 27, 2024 at 6:59 pm
prevent duplicates, ignoring case would be better
February 27, 2024 at 7:21 pm
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".
February 28, 2024 at 1:24 pm
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
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy