Huntfox

 

 1set ANSI_NULLS ON
 2set QUOTED_IDENTIFIER ON
 3go
 4
 5-- =============================================
 6-- Author:        HuntFox
 7-- Create date: 2005.11.23
 8-- Description:    十进制整型转二进制字符串(锁定字符串长的最小值)
 9-- =============================================
10ALTER FUNCTION [dbo].[ToBinarySystemString] 
11(
12@DecimalSystemInt int,
13@BinarySystemStringLen int
14)
15RETURNS NVARCHAR(31)
16AS
17BEGIN
18-- Declare the return variable here
19declare @ResultVar varchar(31)
20set @ResultVar=\'\'
21while (@DecimalSystemInt<>0)
22begin
23   set @ResultVar=@ResultVar+convert(char(1),@DecimalSystemInt%2)
24   set @DecimalSystemInt=@DecimalSystemInt/2
25end
26set @ResultVar=REVERSE (@ResultVar)
27while (Len(@ResultVar)<@BinarySystemStringLen)
28begin
29set @ResultVar=\'0\'+@ResultVar
30end
31RETURN @ResultVar
32END
33
34
35
36
37
38
39
40

 

 

 

 

分类:

技术点:

相关文章:

  • 2021-08-20
  • 2022-12-23
  • 2022-01-18
  • 2021-09-27
  • 2022-12-23
  • 2022-01-11
  • 2022-12-23
  • 2021-10-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2021-09-16
  • 2022-02-08
  • 2021-12-01
相关资源
相似解决方案