http://topic.csdn.net/u/20110407/14/cb4c48ce-5c59-4c7f-892c-f8507d414cd4.html?61055
------解决方案--------------------
路过了!
------解决方案--------------------
------解决方案--------------------
顶顶更健康……
------解决方案--------------------
单纯接分
------解决方案--------------------
进来学习的~~~
------解决方案--------------------
纯洁的围观群众偶遇
------解决方案--------------------
接点水分儿~~~
------解决方案--------------------
.........
------解决方案--------------------
单纯接分
------解决方案--------------------
------解决方案--------------------
-- =============================================
-- Create scalar function (FN)
-- =============================================
IF EXISTS (SELECT *
FROM sysobjects
WHERE name = N'GetExcelColumnTitle')
DROP FUNCTION GetExcelColumnTitle
GO
CREATE FUNCTION GetExcelColumnTitle
(@N bigint
)
RETURNS varchar(10)
AS
BEGIN
if @N<=0
return 'Error:01'
declare @Num bigint,@i smallint
declare @C1 char(1),@C2 char(2),@C3 char(1),@C4 char(1),@C5 char(1),@C6 char(1),@C7 char(1),@C8 char(1)
select @[email protected],@i=1
while @Num>25 and @i<8
begin
if @i=1
set @C1= char([email protected]%26)
else if @i=2
set @C2= char([email protected]%26)
else if @i=3
set @C3= char([email protected]%26)
else if @i=4
set @C4= char([email protected]%26)
else if @i=5
set @C5= char([email protected]%26)
else if @i=6
set @C6= char([email protected]%26)
else if @i=7
set @C7= char([email protected]%26)
set @Num=(@Num/26)-1
set @i = @i+1
end
if @i>8
return 'Error:02'
else if @i=1
set @C1= char([email protected]%26)
else if @i=2
set @C2= char([email protected]%26)
else if @i=3
set @C3=char([email protected]%26)
else if @i=4
set @C4= char([email protected]%26)
else if @i=5
set @C5= char([email protected]%26)
else if @i=6
set @C1= char([email protected]%26)
else if @i=7
set @C7= char([email protected]%26)
else if @i=8
set @C8= char([email protected]%26)
return case when @i=1 then @C1
when @i=2 then @[email protected]
when @i=3 then @[email protected][email protected]
when @i=4 then @[email protected][email protected][email protected]
when @i=5 then @[email protected][email protected][email protected][email protected]
when @i=6 then @[email protected][email protected][email protected][email protected][email protected]
when @i=7 then @[email protected][email protected][email protected][email protected][email protected][email protected]
when @i=8 then @[email protected][email protected][email protected][email protected][email protected][email protected][email protected]
else 'Error:03'
end
END
GO
-- =============================================
-- Example to execute function
-- =============================================
SELECT dbo.GetExcelColumnTitle(703)
--結果:
--AAA
GO
-- 行,谁第一个做出来,我另开一个技术版的给200分!
上述函數可以實現你的要求,3位以下驗算過,但高位數未驗證。兌現承諾,給技術分200分。
------解决方案--------------------
------解决方案--------------------
楼主给力,接分啦
------解决方案--------------------
路过标记
------解决方案--------------------
纯属无聊,微软会让这东西有8位的列?
------解决方案--------------------