Updating column values based on contents of another
795885Sep 4 2010 — edited Sep 6 2010I need assistance in creating a procedure that will update a table based on the last character of a column in another table.
For example, say I have the following two tables:
The PersonData table:
PersonID LastName FirstName
1001 Jones Donna
1002 Ervin Roger
1003 Barga David
The PersonTeam table:
PersonID TeamID
1001
1002
1003
What I would like to do is put together a procedure that will grab the last character of the LastName field, then assign a Team ID based on where that letter is in the alphabet. If the letter falls within the first half of the alphabet, I want to insert the value "A" to TeamID column of the PersonID column. If it falls into the last half of the alphabet, I'd like to insert "B" into the TeamID column.