NTBuddy
New Technology Buddy
Evaluate Email Address
by John C. Marx Wednesday, March 3, 2010 7:16 PM

With email addresses being prevalent this routine will take the input string and return true (1) or false (0) if the email address meets the criteria.

-- This function returns 1 is passed EMAIL Address has valid syntax
-- else 0 will be returned
--
-- Example calls:
-- SELECT dbo.fncValidEmail('goodemail@NimbleUser.com') as 'GOOD'
-- SELECT dbo.fncValidEmail('bademail@NimbleUsercom') as 'BAD'
--
-- Example on how to find all of the bad email addresses in iMIS
-- SELECT ID, FULL_NAME, EMAIL FROM Name WHERE dbo.vaValidEmail(EMAIL) = 0

CREATE FUNCTION [dbo].[fncValidEmail](@EmailAddress VARCHAR(250))
RETURNS BIT
AS
BEGIN    
     DECLARE @ResultBoolean as Bit

     IF ((@EmailAddress <> '') AND (@EmailAddress NOT LIKE '_%@__%.__%'">'_%@__%.__%'))
          BEGIN
               -- Invalid

               SET @ResultBoolean = 0
          END
     ELSE
          BEGIN
               -- Valid

               SET @ResultBoolean = 1
          END

     RETURN @ResultBoolean
END

 

Tags: ,

TSQL

Filter by APML

About the author

Hi, my name is John Marx and I am a software developer who specializes in Microsoft technologies. I specialize in Microsoft ASP.Net, ASP.Net MVC, SQL Server, SharePoint, Windows Phone 7, Windows Forms, WPF, and Dynamics GP and CRM.

I am an early adopter of technology. I ran a BBS (Bulletin Board System) prior to the Internet being available called The Cutting Edge with some success in the early 90’s. I’m an avid woodworker during my off hours and spend time remodeling a fixer upper for enjoyment and time in the offline (real) world.  

Month List

Page List