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
In reply to SQLServer varbinary headache by bfdi533
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |