Re: convert from hexadecimal to a decimal
From: Steve Kass (skass_at_drew.edu)
Date: 10/29/04
- Next message: Steve Kass: "Re: Get the smallest timespan between two entries"
- Previous message: Hugo Kornelis: "Re: convert from hexadecimal to a decimal"
- In reply to: Hugo Kornelis: "Re: convert from hexadecimal to a decimal"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 28 Oct 2004 20:17:10 -0400
Hugo,
Don't forget that if you want something that can be put inline without
a UDF call, you can use something more like this:
create function hexchar2(
@b varchar(10)
) returns int
as begin
return (
select
sum((charindex(right(left(@b,N),1),'123456789ABCDEF'))*POWER(16.,len(@b)-N))
from numbers
where n between 3 and len(@b))
- case when lower(@b) like '0x[89abcdef]'+replicate('[0-9abcdef]',7)
then 0x0100000000 else cast(0 as bigint) end
end
SK
Hugo Kornelis wrote:
>On Wed, 27 Oct 2004 19:31:12 -0500, landung wrote:
>
>
>
>>hi all,
>>
>>when i run this query, it will result this :
>>
>>Server: Msg 207, Level 16, State 3, Procedure hexchar2, Line 5
>>Invalid column name 'n'.
>>
>>May i know the 'n' factor is ???
>>
>>
>
>Hi landung,
>
>It's a column in the numbers table I used for this query.
>
>If you don't have a numbers table yet, check out this link:
>http://www.aspfaq.com/show.asp?id=2516
>
>If you do have a numbers table, but with another column name, change the
>query to reflect the names of your numbers table and column.
>
>Best, Hugo
>
>
- Next message: Steve Kass: "Re: Get the smallest timespan between two entries"
- Previous message: Hugo Kornelis: "Re: convert from hexadecimal to a decimal"
- In reply to: Hugo Kornelis: "Re: convert from hexadecimal to a decimal"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|