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

          常用鏈接

          留言簿(14)

          隨筆檔案(6)

          文章分類(467)

          文章檔案(423)

          相冊

          收藏夾(18)

          JAVA

          搜索

          •  

          積分與排名

          • 積分 - 827232
          • 排名 - 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
          主站蜘蛛池模板: 彭水| 子长县| 渭源县| 阳江市| 彭水| 饶河县| 阜宁县| 繁峙县| 文安县| 依兰县| 富民县| 鞍山市| 万荣县| 库车县| 武功县| 洪江市| 屏山县| 昆明市| 宁海县| 敖汉旗| 苏尼特右旗| 湖州市| 澄城县| 义马市| 新竹县| 隆安县| 南宫市| 霍城县| 晋江市| 大方县| 保亭| 烟台市| 邛崃市| 察隅县| 镇沅| 瓦房店市| 石楼县| 诸暨市| 延寿县| 五原县| 桦甸市|