Re: DEC TO HEX CONVERSION WHILE IMPORTING

From: Steve Kass (skass_at_drew.edu)
Date: 05/15/04


Date: Sat, 15 May 2004 10:12:32 -0400

Mustafa,

  This function returns a varbinary(20) value, so if you are seeing ??
somewhere, then something in your application is not displaying
varbinary values correctly. I don't know how VB6 recordsets display
information of varbinary type. Can your VB recordset object display
what is in this recordset?

select 0x123456AB as aBinaryValue

It sounds like a VB issue, not a SQL Server issue.

Steve Kass
Drew University

mustafa wrote:

>Dear Mr. Steve
>
>i have created user define function dec2hex in sql server
>2000 and when i access it using sql server query analyser
>it give me desired result i.e it convert decimal into
>hexadecimal number
>The query is as follow
>
>select dbo.dec2hex(card_number) as card_number from
>tbltest
>
>But when i used it using VB6 recordset object it show ??
>rather then showing hexadecimal number
>
>thanks
>
>
>
>
>>-----Original Message-----
>>Mustafa,
>>
>> If your decimal values fit into a bigint, you could
>>
>>
>write a
>
>
>>user-defined function (SQL Server 2000 required):
>>
>>create function dec2hex (
>> @decimal bigint
>>) returns varbinary(20) as begin
>> declare @b varbinary(20)
>> set @b = 0x
>> while @decimal > 0 begin
>> set @b = cast(cast(@decimal%256 as tinyint) as binary
>>
>>
>(1)) + @b
>
>
>> set @decimal = @decimal/256
>> end
>> return @b
>>end
>>go
>>
>>select dbo.dec2hex(1)
>>select dbo.dec2hex(2571551874.0)
>>
>>go
>>drop function dec2hex
>>
>>-- Steve Kass
>>-- Drew University
>>-- Ref: 77AF63E1-A927-40A1-A7B0-6EA31F1C80F2
>>
>>MUSTAFA wrote:
>>
>>
>>
>>>I HAVE DECIMAL NUMBER IN MY TEST TABLE COLUMN
>>>
>>>
>CARD_NUMBER
>
>
>>>AS FOLLOWS
>>>2571549730.0
>>>2571549826.0
>>>2571550034.0
>>>2571550210.0
>>>2571550306.0
>>>2571551378.0
>>>2571551586.0
>>>2571551682.0
>>>2571551762.0
>>>2571551874.0
>>>
>>>I WANT TO CREATE A TEMP TABLE AND MOVE THIS COLUMN BUT
>>>BEFORE MOVING IT SHOULD CONVERT INTO HEXADECIMAL NUMBER
>>>WHILE INSERTING INTO TEMP TABLE
>>>
>>>
>>>THANKS
>>>
>>>
>>>
>>>
>>.
>>
>>
>>



Relevant Pages

  • ASP page losing formatting with large ADO recordset
    ... I'm using ASP classic and Ado to pull data from SQL Server 2000. ... I have a recordset with about 6500 rows, ... that I'm trying to display on a page. ... I'm filtering the data with drop downs on entry to reduce the amount ...
    (microsoft.public.inetserver.asp.db)
  • Re: What am I doing wrong?
    ... I do not like a single display, prefering a Flex Grid to display all of the ... Dim rstCompany As Recordset ... Set rstCompany = Nothing ... Private Sub CmdUpdate_Click ...
    (microsoft.public.vb.database.dao)
  • Re: Strange Recordset/Query Problem
    ... > display in SQL Server. ... table names for each field in the SELECT clause, ON clauses, and WHERE ... Also, SQL Server is not case sensitive, so you can save your eyes by using ... the IF statement executes the first condition as it should, ...
    (microsoft.public.inetserver.asp.general)
  • Strange Recordset/Query Problem
    ... Access 2000 database to a SQL Server 2000 database. ... display in SQL Server. ... the IF statement executes the first condition as it should, ...
    (microsoft.public.inetserver.asp.general)
  • MSHFlexgrid not displaying data from ADO data control
    ... if I put it onto a clients machine none of the ... MSHflexgrids display any data. ... The MSHflexgrids data sources are ADO data controls which are ... The SQL Server uses windows network authentication to allow access and I ...
    (microsoft.public.vb.general.discussion)