ms sql server中检测邮件地址的函数
来源:互联网 发布:跟阿铭学linux 第3版 编辑:程序博客网 时间:2024/06/05 04:44
if object_id('fnCheckEmail') is not null
drop function fnCheckEmail
GO
----创建验证函数,返回值为1表示正确,否则格式错误
create function fnCheckEmail(@Email varchar(1000))
returns bit
as
begin
declare @rtv bit
if
charindex(' ',@email) > 0 or /*含有空格*/
len(@email) - len(replace(@email,'.','')) > 1 or /*'.'超过1个*/
len(@email) - len(replace(@email,'@','')) > 1 or /*'@'超过1个*/
right(@email,1) = '.' or /*以'.'结尾*/
right(@email,1) = '@' or /*以'@'结尾*/
left(@email,1) = '.' or /*以'.'开头*/
left(@email,1) = '@' or /*以'.'开头*/
charindex('.',@email)-charindex('@',@email) < 0 or /*'.'在'@'前面*/
charindex('@',@email)-charindex('.',@email) = 1 or /*'@'与'.'相邻*/
charindex('.',@email)-charindex('@',@email) = 1 /*'@'与'.'相邻*/
set @rtv = 0
else
set @rtv = 1
return @rtv
end
GO
----创建测试数据
declare @t table(email varchar(1000))
insert @t
select 'ab.cxyz@s.com' union all
select 'ab@xyz@s.com' union all
select '@abc@xyz.com' union all
select 'abcxyz.com@' union all
select '.abcxyz@com' union all
select 'abc@xyz@com.' union all
select 'ab.c@xyzcom' union all
select 'abc@.com' union all
select 'abc@xyz.com' union all /*格式正确*/
select 'ab c@xyzcom'
----验证
select *,case dbo.fnCheckEmail(email) when 1 then '正确' else '错误' end from @t
----清除测试环境
drop function fnCheckEmail
- ms sql server中检测邮件地址的函数
- 远程检测ms sql server账号安全性
- MS sql server中时间函数用法详解 DATEADD DATEDIFF
- MS SQL Server中dbo
- Oracle和MS SQL server的函数对比
- Oracle和MS SQL server的函数对比
- MS SQL Server和Oracle的常用函数对比
- MS SQL Server 数据库日期时间函数的应用
- MySQL ,MS SQL Server,类似功能的函数
- MS SQL SERVER char 函数显示ASCII的效果
- 检测邮件地址的正则表达式
- Ms SQL Server 中单引号的两种处理技巧
- MS SQL Server 中系统表的作用
- 关于MS SQL Server中DATETIME类型数据的处理
- MS SQL Server 中Convert转换时间的用法
- MS SQL SERVER中时间的精度问题
- QTP中MS SQL SERVER数据库连接的一种简单方法
- Spring连接MS SQL Server中出现的错误
- 在Eclipse中配置JBOSS
- JSP分页技术的实现
- JDOM处理XML快速上手- -
- 通配符的问题?
- web容器加载Servlet,Filter,Listener的顺序
- ms sql server中检测邮件地址的函数
- 怎样在Word中输入数学公式
- 数模集训日~
- 界面设计
- 关于DevExpress.xtraTreeList的使用小集锦。
- 入門 10 - Component 映射
- 世界上最难用的string类
- IBM的踢踏舞和25岁的PC
- Java线程基本用法与同步问题