Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1211443
  • 博文数量: 398
  • 博客积分: 10110
  • 博客等级: 上将
  • 技术积分: 4055
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-23 20:01
个人简介

新博客http://www.cnblogs.com/zhjh256 欢迎访问

文章分类

全部博文(398)

文章存档

2012年(1)

2011年(41)

2010年(16)

2009年(98)

2008年(142)

2007年(100)

我的朋友

分类: Sybase

2008-04-04 11:55:21

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
create function dec_to_oct(@v_dec int)
returns nvarchar(64)
as
begin
declare @v_oct nvarchar(1)
declare @v_oct_final nvarchar(64)
declare @v_temp int
declare @v_mid int
set @v_oct=''
set @v_temp=0
set @v_oct_final=''
while(@v_dec<>0)
 begin
 set @v_temp=@v_dec%8
 set @v_mid=@v_dec/8
set @v_oct=@v_temp
 set @v_oct_final=@v_oct+@v_oct_final
 set @v_dec=@v_mid
 end
return @v_oct_final
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
 
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
create function dec_to_hex(@v_dec int)
returns nvarchar(64)
as
begin
declare @v_hex nvarchar(1)
declare @v_hex_temp int
declare @v_hex_final nvarchar(64)
declare @v_temp nvarchar(1)
declare @v_mid int
set @v_hex=''
set @v_temp=0
set @v_hex_final=''
while(@v_dec<>0)
 begin
 set @v_hex_temp=@v_dec%16
 set @v_mid=@v_dec/16
IF @v_hex_temp=15 SET @v_temp='F'
ELSE IF @v_hex_temp=14 SET @v_temp='E'
ELSE IF @v_hex_temp=13 SET @v_temp='D'
ELSE IF @v_hex_temp=12 SET @v_temp='C'
ELSE IF @v_hex_temp=11 SET @v_temp='B'
ELSE IF @v_hex_temp=10 SET @v_temp='A'
ELSE SET @v_temp=@v_hex_temp
set @v_hex=@v_temp
 set @v_hex_final=@v_hex+@v_hex_final
 set @v_dec=@v_mid
 end
return @v_hex_final
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
 
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
create function dec_to_bin(@v_dec int)
returns nvarchar(64)
as
begin
declare @v_bin nvarchar(1)
declare @v_bin_final nvarchar(64)
declare @v_temp int
declare @v_mid int
set @v_bin=''
set @v_temp=0
set @v_bin_final=''
while(@v_dec<>0)
 begin
 set @v_temp=@v_dec%2
 set @v_mid=@v_dec/2
set @v_bin=@v_temp
 set @v_bin_final=@v_bin+@v_bin_final
 set @v_dec=@v_mid
 end
return @v_bin_final
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
 
阅读(901) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~