用户导入EXCEL数据,用一个存储过程来执行,需要判断其中一列的数据格式,nvchar类型,可以为null值,或全部是数字或是形如"xxx-xxx-xxx"的格式,其中x为数字,且每一部分xxx的数字位数是不固定的,想用正则表达式来做判断,不知道该怎么写啊?
解决方案 »
- SQL2005ReportService 数据展示控件选择【表格】还是【矩阵】?
- 请问如何在sql server 2005 中实现 类似access的'查询表'?
- 所有数据库操作都使用存储过程,真的有必要吗?
- 无果,为有再发第三次贴.
- 在线解决,马上给分
- 请教附加数据库失败的原因
- sqlserver2000 代理 启动后 不久又自动关闭 是咋回事儿?
- 这样通过时间查内容为什么查找不出内容!
- DELPHI+SQL SERVER2000如何在没SQL SERVER2000的机子上用?
- 问一个权限管理问题
- Sql Server 变态问题求救(删除数据库同名用户的问题)[给分帖,zjcxc(邹建) 请进][内有未解决问题,如有人能解惑另外开贴给分]
- 使用visio2001建数据库模型图问题~
or (col not like '%[^0-9-]%'
and len(col) - len(replace(col,'-','')) in(0,2))
from (
select col = null union all
select col = 'abc' union all
select col = 'a7bc' union all
select col = '999' union all
select col = '9-2-3' union all
select col = '9-a-3' union all
select col = '9-2-2-2' union all
select col = '9-a-2-2'
)a
where col is null
or (col not like '%[^0-9-]%'
and len(col) - len(replace(col,'-','')) in(0,2))-- 结果:
NULL
999
9-2-3
但是针对这个问题可以这么做:
if isnumeric(replace('xxx-xxx-xxx','-','')) = 1
print '数字'