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
Thank you very much! Works great.