in reply to SQL Server SID value output as garbage using DBI
What data type is the SID column ?. I suspect it is binary, it only looks like hex in your Management client. This small demo program shows two option, use convert in your SQL statement or unpack the fetched value.
pojuse strict; use DBI; my $dbh = mssql(); # connect # temp test table setup my $t = '#bintest'; $dbh ->do("CREATE TABLE $t (bin1 varbinary(max))"); my $hex_in = '0x151552dabe9d1ce4e8dd6b635f23d4c0'; $dbh->do("INSERT INTO $t (bin1) VALUES ( CONVERT(varbinary(max), ?, 1) )",undef,$hex_in); # my ($bin_out) = $dbh->selectrow_array( "SELECT bin1 FROM $t"); # style 1 adds 0x my ($hex_out) = $dbh->selectrow_array( "SELECT CONVERT(varchar(max),bin1,1) FROM $t"); print "hex input = $hex_in\n"; print "bin out = $bin_out\n"; print 'hex output = 0x',unpack('H*',$bin_out),"\n"; print "hex output = $hex_out\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: SQL Server SID value output as garbage using DBI
by mje (Curate) on Jul 29, 2013 at 16:14 UTC |
In Section
Seekers of Perl Wisdom