in reply to SQLServer varbinary headache
Well, I don't have experience with this, but turning your output into what SQL Server says isn't too hard:
sub bin2hextext { my ($blob) = shift; "0x" . join ('', map {sprintf("%02X",unpack("C",$_))} split(//, $blob)); } my $DSN = 'driver={SQL Server};Server=new-borg;database=master;uid=;pw +d=;'; my $dbh = DBI->connect("dbi:ODBC:$DSN") or die "$DBI::errstr\n"; my $sql = qq{ select * from sysusers }; my $sth = $dbh->prepare ($sql); $sth->execute(); my @varbincolumns = qw(2); while (@row = $sth->fetchrow_array()) { @row[@varbincolumns] = map {bin2hextext($_)} @row[@varbincolumns]; print $#row,':',join(':',@row),"\n"; } $sth->finish();
A more polished version would figure out the contents of the @varbincolumns array using $sth->{TYPE}.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: SQLServer varbinary headache
by fizbin (Chaplain) on Apr 20, 2004 at 19:08 UTC | |
|
Re: Re: SQLServer varbinary headache
by bfdi533 (Friar) on Apr 23, 2004 at 19:53 UTC | |
by fizbin (Chaplain) on Apr 24, 2004 at 00:43 UTC | |
by bfdi533 (Friar) on Apr 26, 2004 at 22:38 UTC |