Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
SqlZ
Yak Posting Veteran
69 Posts |
Posted - 2002-03-14 : 10:49:56
|
| Hi Everyone,Here is the challenge that I am faced with. I have an Email column in a table called UserInfo. I am trying to select all of the distinct domain names from this column Email out of the UserInfo table to run a report.How would I scan the Email field to pick all of the characters after the @ symbol in the email field? I have thought of trimming the left leading characters but there is no set length of the characters in front of the @ in the Email column.I had an idea of a really long way to do this and it was to make everyone's name (name@domain.com) to a specific length of char(50) and then just trim the left 50 characters or something.Any ideas on this would help me out a lot.Thanks in advance.========================My username represents the two things that consume most of my time.SQL, and my Z |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-03-14 : 10:52:28
|
| SELECT DISTINCT SubString(Email, CharIndex('@', Email)+1, 1000) FROM UserInfo |
 |
|
|
joldham
Wiseass Yak Posting Master
300 Posts |
Posted - 2002-03-14 : 10:59:57
|
robvolk,Couldn't you sub LEN(email)-CharIndex('@', Email)+1 for 1000? SELECT DISTINCT SubString(Email, CharIndex('@', Email)+1, LEN(email)-CharIndex('@', Email)+1) FROM UserInfoThen you are not limited to 1000 characters. I would hate to type in that email address. JeremyEdited by - joldham on 03/14/2002 11:01:36 |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-03-14 : 11:06:56
|
Yeah, you could, but I'm pretty sure there's a limit on the length of a domain name, and I'm pretty sure it's less than 1000 characters. You're right, who the hell would want to send an email to someone@the_entire_text_of_War_and_Peace.com??? |
 |
|
|
SqlZ
Yak Posting Veteran
69 Posts |
Posted - 2002-03-14 : 11:24:42
|
Thank you very much! |
 |
|
|
|
|
|
|
|