Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

i'm trying to insert an 8 byte hex number (such as 0x056C6E003DB1E100) into an MS-SQL server 8 byte binary column. I'm using DBI and DBD::ODBC on W2K. I'm trying something like this:
$ctsth = $ctdbh->prepare( "INSERT INTO table(ParentID,ChildID) VALUES +(?,?)" ); $ctsth->bind_param( 1, $hexform1, {TYPE => SQL_BINARY} ); $ctsth->bind_param( 2, $hexform2, {TYPE => SQL_BINARY} ); $ctsth->execute();
however, sqlserver gives me an error saying that it can't implicitly convert a varchar to a binary. does anyone know how i could insert this? michael

Replies are listed 'Best First'.
Re: DBI and inserting binary data
by MZSanford (Curate) on Mar 15, 2002 at 14:52 UTC
    You need to pack your data, maybe like :
    $hexdata1 = pack("H*",$hexform1);
    I believe that will take care of it.
    from the frivolous to the serious