This blog is useful to all my friends who are working on the .Net Technology and wants to enhance their skills as well their problem solving ability.

Tuesday, August 26, 2014

Sql Server Email Validation in Store procedure

IF not (

CHARINDEX(' ',LTRIM(RTRIM(@email))) = 0

AND LEFT(LTRIM(@email),1) <> '@'

AND RIGHT(RTRIM(@email),1) <> '.'

AND CHARINDEX('.',@email ,CHARINDEX('@',@email)) - CHARINDEX('@',@email ) > 1

AND LEN(LTRIM(RTRIM(@email ))) - LEN(REPLACE(LTRIM(RTRIM(@email)),'@','')) = 1

AND CHARINDEX('.',REVERSE(LTRIM(RTRIM(@email)))) >= 3

AND (CHARINDEX('.@',@email ) = 0 AND CHARINDEX('..',@email ) = 0)

)

begin

   // TO DO

end

No comments: