DancingFighterG
asked on
Getting the right username
Ok, thanks to all of you the update works fine. My last problem with this SP is that the store procedure does not accomondate for names that the same first intial and same last name. So for example say you have Sarah Parker and Scott Parker. When I use the SP there will be two sparker. Now in the SP the username that will be put in as a paramete will be sparker or saparker. How do I get it where the SP will look for a 2 character in the name if the previous name already exist? In the end every username HAS to be unique. Here is the query right now:
UPDATE dbo.Users
SET userstat = 'I'
FROM dbo.Users
INNER JOIN dbo.Contact ON dbo.Users.UserCntctID = dbo.Contact.CntctID
WHERE dbo.Users.UserStat = 'A' AND dbo.Users.UserDBMnkr NOT IN ('sysuser', 'RAMQ', 'RAMQ2')
AND LOWER(LEFT(dbo.Contact.Cnt ctFrstNme, 1) + dbo.Contact.CntctLstNme) = 'gmahoney'
UPDATE dbo.Users
SET userstat = 'I'
FROM dbo.Users
INNER JOIN dbo.Contact ON dbo.Users.UserCntctID = dbo.Contact.CntctID
WHERE dbo.Users.UserStat = 'A' AND dbo.Users.UserDBMnkr NOT IN ('sysuser', 'RAMQ', 'RAMQ2')
AND LOWER(LEFT(dbo.Contact.Cnt
What if you have "Sarah Parker" and "Sam Parker"?
ASKER
I didn't think about that senario. So I guess I just need a better solution overall to doing this? Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok, well right now and need a solution for lookup and update. Changing how data is inserted is not possible right now. What if I do something like this. Is there anyway to run some type of conditional statements (which I doubt in sql) that will allow me to say "if duplicate names exist find a unique letter to make the name unique" Usually things like this are done with CF or other languages but maybe there is something with sql that I don't know!! If not then I guess this not possible with the current setup of my system.