_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › 蠍一覲

Contents

1 10讌襯 2 ~ 36讌 譴 襦 覲
2 2讌襯 10讌襦 覲


1 10讌襯 2 ~ 36讌 譴 襦 覲 #

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

2 2讌襯 10讌襦 覲 #

ALTER FUNCTION dbo.ufn_DigitToDec (@Digit VARCHAR(15))
RETURNS INT
AS
/******************************************************************************************
	煙:	2005-12-01
	煙:	http://www.DataBaser.Net/
	SP企:	ufn_DigitToDec
	SP伎:	
		-2讌襯 10讌襦 覲 

	:
		SELECT dbo.ufn_DigitToDec('0010')

	ル:

	覦覲:
	谿語^覓語: 
	觜螻: 
	EDIT HISTORY:
*********************************************************************************************/
BEGIN
	DECLARE @Len INT, @i INT, @r INT, @DigitNum VARCHAR(15)
	SET @Len = LEN(@Digit)
	SET @i = 1
	SET @r = 0
	SET @DigitNum = REVERSE(@Digit)

	WHILE (@i <= @Len)
	BEGIN
		SELECT @r = @r + CASE WHEN 1 = SUBSTRING(@DigitNum, @i, 1) THEN POWER(2, @i-1) ELSE 0 END
		SET @i = @i + 1 
	END

	RETURN @r
END
GO
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:53

蠏碁 螻糾鍵 覓伎 螻 螳語 譟伎 一 . 蠏 螳企 谿曙^ 瑚襯 襴襦 . (覦覦襴れ)