Rank: Administration
Medals: Groups: Administrators
Joined: 10/20/2012 Posts: 106 Points: 327 Location: Tbilisi
Thanks: 0 times Was thanked: 0 time(s) in 0 post(s)
|
ქუოტა (Quote):create function [dbo].[fnsHexToStr](@hex varbinary(8000)) returns varchar(8000) as begin declare @len int = datalength(@hex), @counter int = 1, @res varchar(8000) = '0x', @string char(16) = '0123456789abcdef', @byte binary(1) while(@counter <= @len) begin set @byte = substring(@hex, @counter, 1) set @res += substring(@string, 1 + @byte/16, 1) + substring(@string, 1 + @byte - (@byte/16)*16, 1) set @counter += 1 end return @res end შესრულების მაგალითი : ქუოტა (Quote):declare @hex varbinary(8000) = convert(varbinary,'AB19651111CE') select [dbo].[fnshextostr_](@hex) as [hextostr] -- რეზულტატი: 0x414231393635313131314345
|
|
Apex ltd. http://www.apex.ge
|