What i want to do is extract an email from the FROM field which is stored in the following format
"vini katyal" <vinikatyal@yahoo.com> varchar field
6 6192
I take it that you're looking to do this via a simple SELECT query?
Pat
You need to parse that column. What do you have so far?
~~ CK
You could try something like this. It assumes that you have a table of digits ( tblDigits) from 1 to 100, under a column name digit. - SELECT SUBSTRING(tblContacts.fldEmail, tA.digit + 1, tB.digit - tA.digit - 1)
-
FROM tblContacts, tblDigits tA, tblDigits tB
-
WHERE tblContacts.fldEmail IS NOT NULL
-
AND
-
tB.digit - tA.digit > 0
-
AND
-
tB.digit - tA.digit < LEN(tblContacts.fldEmail)
-
AND
-
SUBSTRING(tblContacts.fldEmail, tA.digit, 1) = '<'
-
AND
-
SUBSTRING(tblContacts.fldEmail, tB.digit, 1) = '>';
I'm sure there are other possibilities.
Pat
- DECLARE @Email varchar(50)
-
SET @Email = '"vini katyal" <vinikatyal@yahoo.com>'
-
SELECT
-
SUBSTRING(@Email,
-
charindex('<',@Email),
-
LEN(@Email)) as [email]
@clvandyke: Good stuff! I cut and pasted it into my SSMS window and it works nicely. It would be great if the OP can weigh in.
Pat
Try this - Declare @str varchar(50) = '"vini katyal" <vinikatyal@yahoo.com>'
Solution 1
------------- - Select
-
Name = Left(@str, PATINDEX('%<%',@str)-1)
-
,Domain = Right(@str,Len(@str)-PATINDEX('%<%',@str)+1)
-
,Email = @str
-
Solution 2 - Select
-
Name = Left(@str, CHARINDEX('<',@str)-1)
-
,Domain = Right(@str,Len(@str)-CHARINDEX('<',@str)+1)
-
,Email = @str
-
Solution 3 - Select
-
Name = REVERSE(STUFF(REVERSE(@str),1,PATINDEX('%<%',REVERSE(@str)),''))
-
,Domain = STUFF(@str,1,PATINDEX('%<%',@str)-1,'')
-
,Email = @str
-
Solution 4 - Select
-
Name = SUBSTRING(@str,1,CHARINDEX('<',@str,1)-1)
-
,Domain = Right(@str,Len(@str)-CHARINDEX('<',@str)+1)
-
,Email = @str
-
In all the four cases the result is as under - Name Domain Email
-
"vini katyal" <vinikatyal@yahoo.com> "vini katyal" <vinikatyal@yahoo.com>
Hope it helps
Sign in to post your reply or Sign up for a free account.
Similar topics
by: jason |
last post by:
Access 2000
I need some help interogatting a table and extracting via ASP the final
field in a row which has a value. In other words, I have a maximum of 10
fields but, at the user level he may...
|
by: Adrian |
last post by:
Hi,
I would like to ask whether do anyone who where or how can i extract email address from Exchange Server or Microsoft Outlook from a Web Application
Adrian
|
by: MLH |
last post by:
I routinely save failure notices from mail servers
bouncing mail back to me that I sent with invalid
address. I would like to write an access procedure
in my contacts database that would open the...
|
by: vjp2.at |
last post by:
I get an email that says "Joe is a bozo, he has 333 baloons" I have
user-defined Outlook fields for BOZO and BALLOONS. I want to have the
program to automagically start a new record and put "joe"...
|
by: visu |
last post by:
I ve a text paragraph something like
sample sample sample sample rr@yahoo.com <ee@ss.comsample sample
sample sample sample sample sample sample sample sample
ds@example.com sample sample sample...
|
by: bcotten |
last post by:
I have a simple Contact Management database. There is a table called 'Contacts' containing a email field. I need to concatenate each record's email field into one text string separated by a...
|
by: Alexander Vasilevsky |
last post by:
How to extract email address from the letter in Outlook Express?
http://www.alvas.net - Audio tools for C# and VB.Net developers
|
by: Alexander Vasilevsky |
last post by:
How to extract email address from the address book in Outlook Express?
http://www.alvas.net - Audio tools for C# and VB.Net developers
|
by: Alexander Vasilevsky |
last post by:
I need extract email address from the address book in Outlook Express also.
http://www.alvas.net - Audio tools for C# and VB.Net developers
|
by: Alexander Vasilevsky |
last post by:
How extract email address from the address book in Outlook Express?
http://www.alvas.net - Audio tools for C# and VB.Net developers
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |