Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2002
    Maynooth, Ireland

    Unanswered: perl win32::ODBC help needed with ms-sql server

    I am not sure if this posrt belongs here
    but here goes....

    I am really stuck with a bit of perl,
    I am working with ms-sql server
    I can make a connection with the database
    and execute the sql and get the result

    the problem is that there is this field Called 'TimeStamp'
    it is simply an incremental binary value that SQL Server guarantees to be unique every time you use it.
    When I look at the table data thought ms query analyser it shows the 'TimeStamp' value in hex
    but the table property show that field as a binary
    when I get that field with perl and display it in the command prompt it lookers like when you open a exe file in
    notepad with all the weird chars.
    Is there any way in perl that I can convert that binary value into and integer,
    I have tried to use unpack but had not results.
    I tried to feed that value back in to ms-sql server I was using .... select cast ( $binVal as integer ) .....
    but the problem there is that in MS query analyser the binary is displayed as hex and in perl $binVal is some kind of pure binary value

    this problem has been wrecking my head for a day and a half now
    I would really appreciate any help that you could give me
    Last edited by wish; 04-02-02 at 10:56.

  2. #2
    Join Date
    Apr 2002
    Maynooth, Ireland
    Ok I have found a solution to my problem I am just putting it up here incase some one else might have this problem.

    If you have retrived a a raw binary value from MS-SQL Server and want to turn it into an int :

    just call

    rawBin2int ( $raw_bin_value )

    here is the above function

    sub rawBin2int
    return hex ( unpack ( "H*" , $_[0] ) );
    # this function takes a raw binary value from
    # a sql server data base and converts it to
    # integer.
    # this function works by taking the raw data
    # as the 1st argument, the unpack function
    # is used as this point with the template set to
    # "H*" this just meens that a Hex string with
    # as many digits as required. After getting the
    # hex number the result is directly passed into
    # a function called hex, when a hex numbder is feb into
    # this function a integer is returned

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts