Re: convert from hexadecimal to a decimal

From: landung (landung.1etdu2_at_mail.mcse.ms)
Date: 10/28/04

  • Next message: Hugo Kornelis: "Re: convert from hexadecimal to a decimal"
    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
     
    

  • Next message: Hugo Kornelis: "Re: convert from hexadecimal to a decimal"

    Relevant Pages

    • Re: Importing from another database on same server using SQL Server Express
      ... I thought this post was considered dead, so I elected to repost the ... "amish" on that group proved to work: ... Please post the COMPLETE query, ... Hugo Kornelis, SQL Server MVP ...
      (microsoft.public.sqlserver.msde)
    • Re: How To Return A "Range Of Rows"??
      ... SET ROWCOUNT. ... there are no rows returned by your query. ... the proc later tries to set a negative ROWCOUNT. ... Hugo Kornelis, SQL Server MVP ...
      (comp.databases.ms-sqlserver)
    • Re: Compare record count in table1 to qty in table2?
      ... Here is a query I'm trying to use and, of course, it does not work: ... INNER JOIN Item_Serial ... Hugo Kornelis, SQL Server MVP ...
      (comp.databases.ms-sqlserver)
    • Re: How To Return A "Range Of Rows"??
      ... Shouldn't I be seeing results with the column headers? ... this just to show that the query works in debug mode? ... Hugo Kornelis, SQL Server MVP ... My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis ...
      (comp.databases.ms-sqlserver)
    • Re: Finding the Shift for current hour
      ... >Hi Hugo Kornelis, ... The query is working fine. ... Are you using Enterprise Manager to isnert the data? ...
      (microsoft.public.sqlserver.mseq)