
用于验证ID号的SQL语句
只需编写如下视图:
创建View eVMutiCard
AS
选择
a.Badgesql 号码验证,a.Name,a.DepIDsql 号码验证,a.Compid,a.JobID,a.Status,a.EmpType,a.ReportTo,
b. 标识
N'ID卡的长度不合理,请注意
来自员工b
(Len(身分证)不在)(15,18)
并且b. 标识不为空)
或者b. 标识为空
全部联盟
选择
a.Badge,a.Name,a.DepID,a.Compid,a.JobID,a.Status,a.EmpType,a.ReportTo,
b. 标识
“上的字符无效”作为备注
来自员工b
Len(b.Identification)在(15,18)中的位置

和同义数字(大写字母(b.Identification),当18然后是子串(b.Identification,1,17)
否则b. 标识结束)= 0
全部联盟
1/5页
选择
a.Badge,a.Name,a.DepID,a.Compid,a.JobID,a.Status,a.EmpType,a.ReportTo,
b. 标识
的出生日期不合理,请注意
来自员工b
Len(b.Identification)在(15,18)中的位置
And(IsDate(Len(b.Identification)= 15时的情况)然后'19'+子字符串(b.Identification,7,2)+'-'+子字符串(b.Identification,9,2)+'- '+子字符串(b.Identification,11,2)
其他
子字符串(b.Identification,7,4)+'-'+子字符串(b.Identification,11,2)+'-'+子字符串(b.Identification,13,2)
End)= 0
还是不(
(Len(b.Identification)= 15时的情况,然后是'19'+子字符串(b.Identification,7,2)+'-'+子字符串(b.Identification,9,2)+'-'+子字符串(b.Identification,11,2)
其他
子字符串(b.Identification,7,4)+'-'+子字符串(b.Identification,11,2)+'-'+子字符串(b.Identification,13,2)
End)在'1900-01-01'和'2079-06-06'之间))
全部联盟
选择
2/5页
a.Badge,a.Name,a.DepID,a.Compid,a.JobID,a.Status,a.EmpType,
a.ReportTo,
b. 标识
N'ID校验位不正确,如备注
来自员工b
其中(Len(身分证)= 18
和子字符串(b.Identification,18,19)<> dbo.GetCheckIDCardCode(b.Identification)
并且b. 标识不为空)
根据国家规定的计算公式,计算出18位ID卡验证码
dbo.GetCheckIDCardCode如下:
创建函数GetCheckIDCardCode(@sfzh char(18))
返回字符(1)
为
开始
声明@r varchar(2)
声明@i int
如果len(@sfzh)<> 18
设置@r = 0
其他
设置@i =强制转换(子字符串(@ sfzh,1,1)为int)* 7
+强制转换(子字符串(@ sfzh,2,1)为int)* 9
+强制转换(子字符串(@ sfzh,3,1)为int)* 10
+强制转换(子字符串(@ sfzh,4,1)为int)* 5
+强制转换(子字符串(@ sfzh,5,1)为int)* 8
3/5页
+强制转换(子字符串(@ sfzh,6,1)为int)* 4
+强制转换(子字符串(@ sfzh,7,1)为int)* 2
+强制转换(子字符串(@ sfzh,8,1)为int)* 1
+强制转换(子字符串(@ sfzh,9,1)为int)* 6
+强制转换(子字符串(@ sfzh,10,1)为int)* 3
+强制转换(子字符串(@ sfzh,11,1)为int)* 7
+强制转换(子字符串(@ sfzh,12,1)为int)* 9
+强制转换(子字符串(@ sfzh,13,1)为int)* 10
+强制转换(子字符串(@ sfzh,14,1)为int)* 5
+强制转换(子字符串(@ sfzh,15,1)为int)* 8
+强制转换(子字符串(@ sfzh,16,1)为int)* 4
+强制转换(子字符串(@ sfzh,17,1)为int)* 2
设置@i = @ i- @ i / 11 * 11
set @r =强制转换((大小写@i
当0到1时
当1到0时
当2点再11点时
当3再9时
4点然后8点时
5到7时
6点到6点时
当7到5时
当8到4时
当9再3时
10点然后2点
else''end)as char)
如果(@r = 11)设置为@ r ='X'
其他设置@r = @r
4/5页
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-164629-1.html
快快