ID card, organization, business license number inspection function

Source: Internet
Author: User
ID card, organization, business license number inspection function. on CSDN, I think it's good to share it with you. no GO ***** Object: UserDefinedFunction [ro]. [wj_ValidateIDC] ScriptDate: 0929201211: 23: 34 ****** SETANSI_NULLSONGOSETQUOTED_IDENTIFIERONGO -- verify the ID card number -- edit

ID card, organization, business license number inspection function. on CSDN, I think it's good to share it with you. no GO/****** Object: UserDefinedFunction [ro]. [wj_ValidateIDC] Script Date: 09/29/2012 11:23:34 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO -- verify the ID card number -- edit

ID card, organization, and business license number check function. We can see it on CSDN and I feel good to share it with you. <无>
GO/***** Object: UserDefinedFunction [ro]. [wj_ValidateIDC] Script Date: 09/29/2012 11:23:34 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO -- verify the ID number -- editor: -- creation Date: -- parameter: @ idc ID No. create FUNCTION [ro]. [wj_ValidateIDC] (@ idc varchar (18) returns bitasbegin declare @ validFactors VARCHAR (17), @ validCodes VARCHAR (11), @ I TINYINT, @ iTemp int select @ validFactors = '79a584216425a5842 ', @ validCodes = '10x98765432', @ I = 1, @ iTemp = 0 -- Verification bit -- add conditions according to the guaranteed database. Otherwise, an error is reported, by wj if (@ idc LIKE 'x % 'OR @ idc LIKE' * % 'OR @ idc LIKE' T % ') RETURN (0) if len (@ idc) <> 15 and len (@ idc) <> 18 -- ID card number is only 15 or 18 bits RETURN (0) if len (@ idc) = 15 -- IF it is a 15-digit ID card, only the verification date IF (ISDATE ('19' + SUBSTRING (@ idc, 7,6) = 0 and '19' + SUBSTRING (@ idc, 7, 6) between '2014-01-01 'and '2014-01-01') RETURN (0) else return (1) -- 18-bit ID card verification date check bit IF (ISDATE (SUBSTRING (@ idc, 7, 8) = 0 and SUBSTRING (@ idc, 1900) between '2017-01-01 'and '2017-01-01') -- Verification date RETURN (0) --- the verification bit starts WHILE @ I <18 begin select @ iTemp = @ iTemp + CAST (SUBSTRING (@ idc, @ I, 1) AS INT) * (CASE SUBSTRING (@ validFactors, @ I, 1) WHEN 'A' THEN 10 else substring (@ validFactors, @ I, 1) END), @ I = @ I + 1 END IF SUBSTRING (@ validCodes, @ iTemp % 11 + 1, 1) = RIGHT (@ idc, 1) RETURN 1 else return 0 RETURN 0 ENDGO/****** Object: UserDefinedFunction [ro]. [wj_ValidateYYZZNo] Script Date: 09/29/2012 11:25:49 *******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO -- function: to verify the Business License number -- editor: -- creation Date: -- parameter: @ ZzNo business license No. create FUNCTION [ro]. [wj_ValidateYYZZNo] (@ ZzNo varchar (15) returns bitasbegin declare @ m INT, @ n INT, @ s INT, @ p INT, @ I INT, @ result int select @ m = 10, @ n = 11, @ p = @ m IF (LEN (LTRIM (RTRIM (@ ZzNo) = 13 and isnumeric (@ ZzNo) = 1) begin RETURN 1 end if (ISNUMERIC (LTRIM (RTRIM (@ ZzNo) = 0) begin RETURN 0 end IF (LEN (LTRIM (RTRIM (@ ZzNo ))) <> 15) begin RETURN 0 end set @ I = 1 WHILE @ I <= 14 begin set @ s = SUBSTRING (@ ZzNo, @ I, 1) SET @ p = @ p + @ s SET @ p = @ p % @ m IF @ p = 0 begin set @ p = @ m end set @ p = @ p * 2 SET @ p = @ p % @ n SET @ I = @ I + 1 END SET @ p = @ p + SUBSTRING (@ ZzNo, 15, 1) SET @ p = @ p % @ m IF @ p = 1 begin set @ result = 1 end else begin set @ result = 0 endRETURN @ resultENDGO/***** Object: userDefinedFunction [ro]. [wj_ValidateZZJGNo] Script Date: 09/29/2012 11:26:32 *******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO -- function: Organization ID verification -- editor: -- creation Date: -- parameter: @ ZZJGNo: Organization No. alter function [ro]. [wj_ValidateZZJGNo] (@ ZZJGNo varchar (20) returns bitasbegindeclare @ c varchar (20), @ zz int, @ z int, @ I INT, @ jaz VARCHAR (30 ), @ C9 VARCHAR (10) SET @ ZZJGNo = UPPER (@ ZZJGNo) SET @ I = 1 WHILE @ I <= 8 BEGINSET @ c = SUBSTRING (@ ZZJGNo, @ I, 1) IF @ c> = 'A' AND @ c <= 'Z' begin set @ Z = (ASCII (@ c)-55) * (CASE @ I WHEN 1 THEN 3 WHEN 2 THEN 7 WHEN 3 THEN 9 WHEN 4 THEN 10 WHEN 5 THEN 5 WHEN 6 THEN 8 WHEN 7 THEN 4 WHEN 8 THEN 2 END) end else if @ c> = '0' AND @ c <= '9' begin set @ z = CONVERT (NUMERIC, @ c) * (CASE @ I WHEN 1 THEN 3 WHEN 2 THEN 7 WHEN 3 THEN 9 WHEN 4 THEN 10 WHEN 5 THEN 5 WHEN 6 THEN 8 WHEN 7 THEN 4 WHEN 8 THEN 2 END) ENDELSEBEGINRETURN 0END SET @ zz = ISNULL (@ zz, 0) + @ z SET @ I = @ I + 1 ENDSET @ jaz = 11-(@ zz % 11) IF @ jaz = 10 BEGINSET @ C9 = 'X' end else if @ jaz = 11 BEGINSET @ C9 = '0' endelse beginset @ C9 = LTRIM (RTRIM (@ jaz )) end if @ ZZJGNO = SUBSTRING (@ ZZJGNO,) + @ C9BEGIN RETURN 1 end if @ ZZJGNO = SUBSTRING (@ ZZJGNO) + '-' + @ C9BEGIN RETURN 1 ENDIF @ ZZJGNO = SUBSTRING (@ ZZJGNO,) + '-' + @ C9BEGIN RETURN 1 ENDIF @ ZZJGNO = SUBSTRING (@ ZZJGNO) + ''+ @ C9BEGIN RETURN 1 end return 0END

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.