Found a version of this on the net. removed the loop and if/thens and made it a case statement
2004-03-11: Changed '@%@' to '%@%@%'
Found a version of this on the net. removed the loop and if/thens and made it a case statement
2004-03-11: Changed '@%@' to '%@%@%'
create FUNCTION ValidateEmail (@email varChar(255)) RETURNS bit AS begin return ( select Case When @Email is null then 0--NULL Email is invalid Whencharindex(' ', @email) <> 0 or--Check for invalid character charindex('/', @email) <> 0 or--Check for invalid character charindex(':', @email) <> 0 or --Check for invalid character charindex(';', @email) <> 0 then 0 --Check for invalid character When len(@Email)-1 <= charindex('.', @Email) then 0--check for '%._' at end of string When @Email like '%@%@%'or @Email Not Like '%@%.%' then 0--Check for duplicate @ or invalid format Else 1 END ) end