_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › fn_hexstrTovarbin

  1. CREATE FUNCTION fn_hexstrtovarbin(@input varchar(8000))
  2. returns varbinary(8000)
  3. AS
  4. begin
  5. declare @result varbinary(8000)
  6.  
  7. IF @input IS NOT NULL
  8. begin
  9. declare @i int, @l int
  10.  
  11. SELECT @result = 0x, @l = len(@input) / 2, @i = 2
  12.  
  13. while @i <= @l
  14. begin
  15. SET @result = @result +
  16. cast(cast(case lower(substring(@input, @i*2-1, 1))
  17. when '0' then 0x00
  18. when '1' then 0x10
  19. when '2' then 0x20
  20. when '3' then 0x30
  21. when '4' then 0x40
  22. when '5' then 0x50
  23. when '6' then 0x60
  24. when '7' then 0x70
  25. when '8' then 0x80
  26. when '9' then 0x90
  27. when 'a' then 0xa0
  28. when 'b' then 0xb0
  29. when 'c' then 0xc0
  30. when 'd' then 0xd0
  31. when 'e' then 0xe0
  32. when 'f' then 0xf0
  33. end AS tinyint) |
  34. cast(case lower(substring(@input, @i*2, 1))
  35. when '0' then 0x00
  36. when '1' then 0x01
  37. when '2' then 0x02
  38. when '3' then 0x03
  39. when '4' then 0x04
  40. when '5' then 0x05
  41. when '6' then 0x06
  42. when '7' then 0x07
  43. when '8' then 0x08
  44. when '9' then 0x09
  45. when 'a' then 0x0a
  46. when 'b' then 0x0b
  47. when 'c' then 0x0c
  48. when 'd' then 0x0d
  49. when 'e' then 0x0e
  50. when 'f' then 0x0f
  51. end AS tinyint) AS BINARY(1))
  52. SET @i = @i + 1
  53. end
  54. end
  55.  
  56. RETURN @result
  57. end
  58.  
* IE拭辞 社什 差紫獣 匝郊嘩 照喫. MS-Word 去拭 細食 隔生室推. 匝郊嘩 鞠澗 崎虞酔煽: Chrome, Opera, Safari
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:52

伎 企ゼ 覲企 蟆 讌() 伎 企ゼ 豢豌 蟆 (篁)企 伎 企ゼ 企れ企 蟆 (臂)企. (螻旧)