_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
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

覓企 覓殊企 讌碁ゼ 磯 襯企 豺讌 螻 讌襯 螳豢 螳螻 讌企伎 襦 螳 襯 螳豢 螳朱 企 蟾 螻葛 襾碁蟇磯Μ讌 螻 れ願 蠍磯ゼ 螳讌 螳螻 レ覓殊 襷 螳覃 螻 襷讌 豌覈 螳朱 螻褐 蟇一 覃襴 襯伎襷 覓殊企襴 覯 朱 螳讌 螳. 豌讌 願朱 企伎螻 襷覓殊 願朱 伎螳覃 朱 願朱 至 襷 願朱 伎覃 襷覓殊 願朱 覦襯願 蟆企. 願 讌襦 螳 覓殊 譬 伎企. ( <<語>>)