威望0
积分7856
贡献0
在线时间758 小时
UID1
注册时间2021-4-14
最后登录2024-11-10
管理员
- UID
- 1
- 威望
- 0
- 积分
- 7856
- 贡献
- 0
- 注册时间
- 2021-4-14
- 最后登录
- 2024-11-10
- 在线时间
- 758 小时
|
create FUNCTION [dbo].[F_15t18](@idcaid varchar(20))
RETURNS varchar(20)
AS
BEGIN
declare @s int
set @idcaid=ltrim(rtrim(@idcaid))
if len(@idcaid)!=15
return ''
set @idcaid=LEFT(@idcaid,6) + '19' +right(@idcaid,9)
set @s=(cast(substring(@idcaid,1,1) as int)*7
+cast(substring(@idcaid,2,1) as int)*9
+cast(substring(@idcaid,3,1) as int)*10
+cast(substring(@idcaid,4,1) as int)*5
+cast(substring(@idcaid,5,1) as int)*8
+cast(substring(@idcaid,6,1) as int)*4
+cast(substring(@idcaid,7,1) as int)*2
+cast(substring(@idcaid,8,1) as int)*1
+cast(substring(@idcaid,9,1) as int)*6
+cast(substring(@idcaid,10,1) as int)*3
+cast(substring(@idcaid,11,1) as int)*7
+cast(substring(@idcaid,12,1) as int)*9
+cast(substring(@idcaid,13,1) as int)*10
+cast(substring(@idcaid,14,1) as int)*5
+cast(substring(@idcaid,15,1) as int)*8
+cast(substring(@idcaid,16,1) as int)*4
+cast(substring(@idcaid,17,1) as int)*2) % 11
if @s=0 set @idcaid=@idcaid+'1'
if @s=1 set @idcaid=@idcaid+'0'
if @s=2 set @idcaid=@idcaid+'X'
else set @idcaid=@idcaid+cast(12-@s as char(1))
RETURN @idcaid
END |
|