ALTER FUNCTION dbo.ufn_DecToDigit (@Dec BIGINT, @base TINYINT)
RETURNS VARCHAR(63) --
AS
/******************************************************************************************
煙: 2005-12-01
煙: http://www.DataBaser.Net/
SP企: ufn_DecToDigit
SP伎:
-10讌襯 2 ~ 36讌 譴 襦 覲
:
SELECT dbo.ufn_DecToDigit(17, 2) -- 10讌 17 2讌襦 覲
SELECT dbo.ufn_DecToDigit(17, 8) -- 10讌 17 8讌襦 覲
SELECT dbo.ufn_DecToDigit(17, 13) -- 10讌 17 13讌襦 覲
ル:
@ItemInfo BIGINT :
, @base TINYINT
覦覲:
谿語^覓語:
觜螻:
EDIT HISTORY:
*********************************************************************************************/
BEGIN
--ル 螳 2讌襦 襴
DECLARE
@r AS VARCHAR(63)
, @alldigits AS VARCHAR(36)
--SET @base = 2 --2讌覃 2, 8讌覃 8, 16讌覃 16
SET @alldigits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
SET @r = ''
WHILE @Dec > 0
BEGIN
SET @r = substring(@alldigits, @Dec % @base + 1, 1) + @r
SET @Dec = @Dec / @base;
END
RETURN @r
END
GO