Re: Trim Email Address down to domain only
From: Douglas J. Steele (NOSPAM_djsteele_at_NOSPAM_canada.com)
Date: 10/28/04
- Next message: Scott: "Re: Comparing Employee Records"
- Previous message: John Spencer (MVP): "Re: Trim Email Address down to domain only"
- In reply to: Steve Roberts: "Re: Trim Email Address down to domain only"
- Next in thread: John Spencer (MVP): "Re: Trim Email Address down to domain only"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 27 Oct 2004 20:05:10 -0400
Mental lapse (again!) on my part. SQL Server uses single quotes, not double
quotes.
Try
SELECT DISTINCT SubString(EMail_Address, PatIndex('@', EMail_Address) + 1,
Len(EMail_Address) - PatIndex('@', EMail_Address))
FROM dbo.CLIENT_CONTACT
You could also use CharIndex instead of PatIndex
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Steve Roberts" <Stever@Discussiongroups.com> wrote in message news:OtEUtpHvEHA.1928@TK2MSFTNGP10.phx.gbl... > Hmm so much for copy paste! It still gives me the error. I keep looking at > it and I don't see any problems. > > SELECT DISTINCT SubString(EMail_Address, PatIndex("@", EMail_Address) + 1, > Len(EMail_Address) - PatIndex("@", EMail_Address)) > FROM dbo.CLIENT_CONTACT > > Thanks > > Steve > > > > "Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message > news:Of%239ozGvEHA.1308@TK2MSFTNGP09.phx.gbl... > > What's with the [@]? The code I posted used "@" > > > > -- > > Doug Steele, Microsoft Access MVP > > http://I.Am/DougSteele > > (no e-mails, please!) > > > > > > > > "Steve Roberts" <Stever@Discussiongroups.com> wrote in message > > news:ejcTRKDvEHA.3896@TK2MSFTNGP09.phx.gbl... > >> When I check this query I get an invalid column name '. error. I verified > >> the spelling of everything and that looks good. I looked up all of the > >> commands that arebeign used in the SQL BOL and I can't figure out what is > >> wrong. > >> Here is how I inserted your code: > >> > >> SELECT DISTINCT > >> SUBSTRING(EMAIL_ADDRESS, PATINDEX([@], EMAIL_ADDRESS) + 1, > >> LEN(EMAIL_ADDRESS) - PATINDEX([@], EMAIL_ADDRESS)) > >> FROM dbo.CLIENT_CONTACT > >> > >> Thanks again > >> > >> steve > >> > >> > >> > >> > >> "Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message > >> news:OlesEE8uEHA.3228@TK2MSFTNGP12.phx.gbl... > >> > Sorry: I totally missed the ADP part. > >> > > >> > I think you can use: > >> > > >> > SubString(EMail_Address, PatIndex("@", EMail_Address) + 1, > >> > Len(EMail_Address) - PatIndex("@", EMail_Address)) > >> > > >> > If EMail_Address is Char (as opposed to Varchar), you'll probably have > > to > >> > use Len(RTrim(EMail_Address)) instead. > >> > > >> > -- > >> > Doug Steele, Microsoft Access MVP > >> > http://I.Am/DougSteele > >> > (no e-mails, please!) > >> > > >> > > >> > > >> > "Steve Roberts" <Stever@Discussiongroups.com> wrote in message > >> > news:OnNeGF7uEHA.3276@TK2MSFTNGP15.phx.gbl... > >> >> I spoke too soon. Both solutions produce an ADO error: INSTR is not a > >> >> recognized function name. > >> >> > >> >> Any Ideas? > >> >> > >> >> "John Spencer (MVP)" <spencer4@comcast.net> wrote in message > >> >> news:417ED2AC.62ACBB0D@comcast.net... > >> >> > Not sure if this will work with an ADP. > >> >> > > >> >> > SELECT DISTINCT > >> >> > RIGHT(EMail_ADDRESS,InStr(1,EMail_Address,"@")+1) as DomainOnly > >> >> > FROM dbo.Client_Contact > >> >> > WHERE Email_Address Is Not Null > >> >> > > >> >> > Steve Roberts wrote: > >> >> >> > >> >> >> Adp 2003 + SQL 7.0 > >> >> >> > >> >> >> I am trying to create a list of unique domains that we send email > >> >> >> to > >> > for > >> >> >> our > >> >> >> spam filter. The column I am pulling from has the full > > user@domain.com > >> >> >> and I > >> >> >> need to create a query that just has domain.com in it. > >> >> >> > >> >> >> SELECT DISTINCT EMAIL_ADDRESS > >> >> >> FROM dbo.CLIENT_CONTACT > >> >> >> WHERE (EMAIL_ADDRESS <> '""') > >> >> >> > >> >> >> Thanks in advance.. > >> >> >> Steve > >> >> > >> >> > >> > > >> > > >> > >> > > > > > >
- Next message: Scott: "Re: Comparing Employee Records"
- Previous message: John Spencer (MVP): "Re: Trim Email Address down to domain only"
- In reply to: Steve Roberts: "Re: Trim Email Address down to domain only"
- Next in thread: John Spencer (MVP): "Re: Trim Email Address down to domain only"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|