bfdi533 has asked for the wisdom of the Perl Monks concerning the following question:
I am using DBI::ODBC to connect to MS SQL Server 2000 and I need to pull the SID for a given user out of the sysusers table. This column is varbinary though and is creating havoc on my output.
Here is some sample code:
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(); while (@row = $sth->fetchrow_array()) { print $#row,':',join(':',@row),"\n"; } $sth->finish();
Some output from this is here:
But, when I query this in SQL Server I get the following:5:14:IUSRBEVO:☺♣ ♣§ ₧§J|╝zê∟ +j7╞? : :2000-09-22 14:08:48.217:2000-09-22 14:08:48.217:0::0:: +1:1:1:0:1:0:0:0:0 7:2:ARAdmin:♥┼ºoAá╥◄╜╜ á$J§╛ +:@:2003-02-18 13:08:06.370:2003-02-18 13:08:06.697:0::0::1:1:0:0:0:1: +0:0:0
5:14:IUSRBEVO:0x0105000000000005150000009E15AE084A7CBC7A881C6A37C63F00 +00:0x00:2000-09-22 14:08:48.217:2000-09-22 14:08:48.217:0:NULL:0:NULL +:1:1:1:0:1:0:0:0:0 7:2:ARAdmin:0x03C5A76F41A0D211BDBD00A0244A15BE:0x40:2003-02-18 13:08:0 +6.370:2003-02-18 13:08:06.697:0:NULL:0:NULL:1:1:0:0:0:1:0:0:0
Notice that the 4th column in SQL Server starts with "0x" and then the SID but the text I get does not as it is being interpreted as a binary number.
Anyone have experience with this? Getting text out of a varbinary column?
Ed
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: SQLServer varbinary headache
by Util (Priest) on Apr 20, 2004 at 19:03 UTC | |
|
Re: SQLServer varbinary headache
by fizbin (Chaplain) on Apr 20, 2004 at 19:02 UTC | |
by fizbin (Chaplain) on Apr 20, 2004 at 19:08 UTC | |
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 | |
|
Re: SQLServer varbinary headache
by mpeppler (Vicar) on Apr 21, 2004 at 07:08 UTC | |
by bfdi533 (Friar) on Apr 23, 2004 at 19:48 UTC | |
by mpeppler (Vicar) on Apr 24, 2004 at 06:32 UTC |