How to encode int with base32 in sql server 2008

I want to encode an INT string in BASE32 in SQL Server 2008.

Any suggestions for a built-in function, or possibly a custom function?

thanks

+1
source share
3 answers

Pretty sure it will require some debugging, but should be close. I translated from the C # function that I found, which converts base10 to base32.

CREATE FUNCTION dbo.Base10toBase32 (@pInput int) RETURNS varchar(100) AS BEGIN Declare @pSet char(32) Declare @pRslt varchar(100) Declare @pRmdr int Declare @pPos int SET @pSet = '0123456789ABCDEFGHIJKLMNOPQRSTUV' SET @pPos = @pInput WHILE @pPos > 0 BEGIN SET @pRmdr = @pPos % 32 SET @pPos = @pPos / 32 SET @pRslt = SubString(@pSet,@pRmdr+1,1) + @pRslt END RETURN @pRslt END 
+1
source

If you're looking for a readable base32 base32, check out Crockford's: http://www.crockford.com/wrmg/base32.html

It seems that the Dell service tag - avoids the confusion between 1 0 i L, etc.

+1
source

Source: https://habr.com/ru/post/1391319/


All Articles