Skip to main content
Solved

11-Proef

  • December 14, 2020
  • 2 replies
  • 136 views

Theo Neeskens
Sidekick
Forum|alt.badge.img+2

Has anybody implemented the “11-Proef” for BSN numbers, and is willing to share the code please?

Since this is a typical Dutch question:

Heeft iemand al eens een 11-proef gebouwd voor burgerservicenummers, of eventueel bankrekeningnummers? 

(Voor mij was de laatste keer 25-30 jaar geleden in BASIC en COBOL….)

https://nl.wikipedia.org/wiki/Elfproef

Best answer by Erwin Ekkel

Hello Theo,

I have not, but the basic logic seems to be multiply number by position add the numbers and if BSN multiply last number by -1. Then check if the result is a positive integer (bigger than 0). 

The code below should do the trick. You can test it with the example BSN numbers 111222333 and 123456782

For bank account you need to remove the -1 part. 

 

declare @int int
declare @position int
declare @check int
set @position = 1
set @check = 0
set @int = 111222333 
;
while @position < 10
begin
   set @check += (select SUBSTRING(cast(@int as varchar),@position,1) * case when (10-@position) = 1 then -1 else (10-@position) end)
   ;
   set @position += 1 
end
;
if (@check / 11.0) = cast(@check / 11 as int)
and (@check / 11.0) <> 0
begin
 select 'true'
end
else
begin
 select 'false'
end

View original
This topic has been closed for comments

Forum|alt.badge.img+17

Hello Theo,

I have not, but the basic logic seems to be multiply number by position add the numbers and if BSN multiply last number by -1. Then check if the result is a positive integer (bigger than 0). 

The code below should do the trick. You can test it with the example BSN numbers 111222333 and 123456782

For bank account you need to remove the -1 part. 

 

declare @int int
declare @position int
declare @check int
set @position = 1
set @check = 0
set @int = 111222333 
;
while @position < 10
begin
   set @check += (select SUBSTRING(cast(@int as varchar),@position,1) * case when (10-@position) = 1 then -1 else (10-@position) end)
   ;
   set @position += 1 
end
;
if (@check / 11.0) = cast(@check / 11 as int)
and (@check / 11.0) <> 0
begin
 select 'true'
end
else
begin
 select 'false'
end


Theo Neeskens
Sidekick
Forum|alt.badge.img+2

Thank you very much! Works great.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings