Re: convert from hexadecimal to a decimal
From: landung (landung.1etdu2_at_mail.mcse.ms)
Date: 10/28/04
- Previous message: rdbrock: "Re: SQL Query Analyzer does not open"
- In reply to: Hugo Kornelis: "Re: convert from hexadecimal to a decimal"
- Next in thread: Hugo Kornelis: "Re: convert from hexadecimal to a decimal"
- Reply: Hugo Kornelis: "Re: convert from hexadecimal to a decimal"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 27 Oct 2004 19:31:12 -0500
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 ???
Hugo Kornelis wrote:
> *On Wed, 29 Sep 2004 00:27:03 -0400, Steve Kass wrote:
>
> >This is not too efficient, but it should do the trick.
>
> Hi Steve,
>
> How about using a numbers table to speed it up?
>
> create function hexchar2(
> @b varchar(10)
> ) returns int
> as begin
> declare @n bigint
> set @b = substring(@b,3,8)
> set @n = (select
> sum((charindex(left(right(@b,n),1),'0123456789ABCDEF')-1)*POWER(16,(n-1)))
> from dbo.numbers
> where n between 1 and len(@b))
> return
> case when @n >= 0X80000000
> then @n - 0x0100000000
> else @n end
> end
> go
>
>
> Best, Hugo
> --
>
> (Remove _NO_ and _SPAM_ to get my e-mail address) *
-- landung ------------------------------------------------------------------------ Posted via http://www.mcse.ms ------------------------------------------------------------------------ View this thread: http://www.mcse.ms/message1108509.html
- Previous message: rdbrock: "Re: SQL Query Analyzer does not open"
- In reply to: Hugo Kornelis: "Re: convert from hexadecimal to a decimal"
- Next in thread: Hugo Kornelis: "Re: convert from hexadecimal to a decimal"
- Reply: Hugo Kornelis: "Re: convert from hexadecimal to a decimal"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|