How to verify the email is valid or not?
For example:
test@test.com
- validtest@@.com
- invalidtest@.com
- invalid
How to verify the email is valid or not?
For example:
test@test.com
- valid test@@.com
- invalid test@.com
- invalidHere is an example of creating a table with specific rules for mail with address (regexp). Then an example with sql query pattern (Regexp). With this you should be able to do what you want
Create table with regexp
create table Contacts (
FirstName nvarchar(30),
LastName nvarchar(30),
EmailAddress nvarchar(30) CHECK (dbo.RegExMatch('[a-zA-Z0-9_\-]+@([a-zA-Z0-9_\-]+\.)+(com|org|edu|nz)', EmailAddress)=1),
USPhoneNo nvarchar(30) CHECK (dbo.RegExMatch('\([1-9][0-9][0-9]\) [0-9][0-9][0-9]\-[0-9][0-9][0-9][0-9]', UsPhoneNo)=1))
INSERT INTO [talend].[dbo].[Contacts]
([FirstName]
,[LastName]
,[EmailAddress]
,[USPhoneNo])
VALUES
('Hallam'
,'Amine'
,'mhallam@talend.com’
,'0129-2090-1092')
,( 'encoremoi'
,'nimportequoi'
,'amine@zichji.org'
,'(122) 190-9090')
GO
Execute request sql with regexp
SELECT [FirstName]
,[LastName]
,[EmailAddress]
,[USPhoneNo]
FROM [talend].[dbo].[Contacts]
where [talend].[dbo].RegExMatch([EmailAddress],'[a-zA-Z0-9_\-]+@([a-zA-Z0-9_\-]+\.)+(com|org|edu|nz|au)') = 1
Function Code
using System;
using Microsoft.SqlServer.Server;
using System.Text.RegularExpressions;
public partial class RegExBase
{
[SqlFunction(IsDeterministic = true, IsPrecise = true)]
public static int RegExMatch( string matchString , string pattern)
{
Regex r1 = new Regex(pattern.TrimEnd(null));
if (r1.Match(matchString.TrimEnd(null)).Success == true)
{
return 1 ;
}
else
{
return 0 ;
}
}
};
For more explication show here ths tutorial -> http://www.google.ch/url?sa=t&rct=j&q=&esrc=s&source=web&cd=6&ved=0CGkQFjAF&url=http%3A%2F%2Fwww.talendforge.org%2Fbugs%2Ffile_download.php%3Ffile_id%3D4729%26type%3Dbug&ei=f8C9UKTMBNSN4gTo0IHYDg&usg=AFQjCNG-ezRtC9TdcJXuXGl4T8KX4zbUww&sig2=Fpgm5UTYOK4dpsaMfNCCyQ&cad=rja
I hope this help you
There is one newer efficient way to do that is to extend .Net functionality for SQL.
Please check details at http://msdn.microsoft.com/en-us/magazine/cc163473.aspx
One ready source code for regex match is at http://www.codeproject.com/Articles/42764/Regular-Expressions-in-MS-SQL-Server-2005-2008.
Now a simple regex for Email should do the magic for you Hope that helps
Some years back I wrote a program about Pattern Matching – Email Validation. Hope that may help you.