隨筆 - 6  文章 - 129  trackbacks - 0
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(14)

          隨筆檔案(6)

          文章分類(467)

          文章檔案(423)

          相冊

          收藏夾(18)

          JAVA

          搜索

          •  

          積分與排名

          • 積分 - 827168
          • 排名 - 49

          最新評論

          閱讀排行榜

          評論排行榜


          十進制轉十六進制
          /****** Object: Function [dbo].[IntToHex]   Script Date: 2013-10-30 16:22:15 ******/
          USE [ZBP];
          GO
          SET ANSI_NULLS OFF;
          GO
          SET QUOTED_IDENTIFIER ON;
          GO
          CREATE FUNCTION [dbo].[IntToHex]
          (@IntNum bigint)
          RETURNS varchar(16)
          AS
          BEGIN
          declare @Mods bigint, @res varchar(16)
          set @res=''
          while @IntNum <> 0
          begin
          set @Mods = @IntNum % 16
          if @Mods > 9
          set @res = Char(Ascii('A')+@Mods-10)+@res
          else
          set @res = Cast(@Mods as varchar(4))+@res
          set @IntNum = @IntNum/16
          end
          return @res
          END
          GO
          十六進制轉十進制
          /****** Object: Function [dbo].[HexToInt]   Script Date: 2013-10-30 16:22:04 ******/
          USE [ZBP];
          GO
          SET ANSI_NULLS OFF;
          GO
          SET QUOTED_IDENTIFIER ON;
          GO
          CREATE FUNCTION [dbo].[HexToInt]
          (@hex varchar(100))
          RETURNS int
          AS
          BEGIN
          Declare @result bigint,@iPos int,@iTmp bigint,@iLoop int,@tmp varchar(16)
              Set @tmp = '0123456789ABCDEF'
              Select @result = 0,@iPos = 0
              While @iPos <   Len(@hex)
              Begin
                    Set  @iTmp = 
                         CharIndex(substring(@hex,Len(@hex) - @iPos,1),@tmp)-1
                    Set @iLoop = 1
                    While @iLoop <= @iPos and @iTmp > 0
                    begin
                        Set @iTmp = @iTmp * 16
                        Set @iLoop = @iLoop + 1
                    end
                    Set @result = @result + @iTmp
                    Set @iLoop = @iLoop + 1     
                    Set @iPos = @iPos + 1
              End
              return @result
          END
          GO


          posted on 2013-11-08 16:54 Ke 閱讀(1249) 評論(0)  編輯  收藏 所屬分類: sql server
          主站蜘蛛池模板: 堆龙德庆县| 深泽县| 伊金霍洛旗| 威海市| 东乡| 阿图什市| 康定县| 廉江市| 延吉市| 新宁县| 望城县| 古浪县| 合水县| 托里县| 巧家县| 越西县| 镇远县| 邓州市| 金华市| 鄂托克前旗| 寻乌县| 柳林县| 贡山| 射洪县| 沛县| 博湖县| 高密市| 高台县| 沾化县| 油尖旺区| 苗栗市| 资阳市| 高雄市| 大洼县| 襄城县| 都江堰市| 鹿泉市| 靖江市| 肥东县| 上虞市| 肇源县|