Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help creating email address' from first and last name table 2

Status
Not open for further replies.

jmslandon

IS-IT--Management
Jun 2, 2009
16
US
Hi,

If I have a table with empID, firstname, lastname and I have 300 employees on this table. Is there a way I can add a new column called "email" and automatically populate in each employee's email as left(firstname, 1) + lastname + 'test.com'

example: james landon ----> jlandon@test.com
 
You can set default value to be
left(firstName,1) + lastName + '@' + 'test.com'

 
OR
After you create that column you run the following update:
Code:
UPDATE YourTable SET eMail = left(firstName,1) +
                              lastName + '@test.com'
That is valid if lastName is N/VARchar field. If it is fixed length you must use LTRIM(RTRIM()) functions.

I am against the default here, just because some empl. can have NO eMails :) or even they can have eMails which is not obey the rule. What if you have 30 John Smith? what will be their eMails? OK I agree that for the existing persons you could have something user can change, but for newly added?


Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Thank you both... Kinda embarrassing seeing how simple it was.

How did you add the CODE text box?
 
Whay if you have, for example, a John Smith and a James Smith? That would cause a conflict.

Our rule is:

The first user gets jsmith@test.com.

For subsequent users, add the middle initial (jrsmith@test.com).

If subsequent users have no middle name or the same initial, append a sequential number (jsmith1@test.com).



-- Francis
I'd like to change the world, but I can't find the source code.
 
Just click on "Process TGML" link (not the checkbox) and you will see all supported tags here. For the code blocks use
[tt]
[ code ]
[ /code ]
[/tt]
w/o spaces in the square brackets

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
That's what im trying to figure out next. I have a james and a jeff landon both without middle initials. How would i append a sequential number to the email address?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top