May 9, 2003 at 2:41 am
Hi All,
Here i am facing the problem while converting Hexadecimal values to Ascii.
If i give the qry : select ASCII(0x4F)
Result : 79
fine. i want 4F has to be passed from dynamically like :
DECLARE @s-2 varchar(2)
declare @s1 varchar(2)
set @s-2='0x'
set @s1='4F'
select ASCII((CONVERT(VARCHAR, (@s + @s1))))
Result is giving some thing diff.
Is this correct way? or how ot do??
Pls help me on this!!
May 9, 2003 at 3:31 am
Not Entirely sure what you want but try this:
It Will give you the ascii number represented by the hexadecimal number
declare @s1 varchar(2)
,@ii int
,@bin varbinary(10)
set @s1='14'
set @bin = 0
set @ii = 1
While @ii <= Len(@s1)Begin
Select @Bin = @Bin +( Power( 16, @ii - 1 ) *
Convert( Int, Substring( Reverse( @s1 ), @ii, 1 ) ) )
Select @Bin
Set @ii = @ii +1
End
Select Convert( int, @bin )
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply