Context: querying from Windows 2008 running Perl
Driver: SQL Server Native Client 10.0 (Microsoft SQL Server 2008 Feature Pack - April 2009)
Perl Module DBD::ODBC
$dbh->selectall_arrayref("SELECT TOP 1001 userid FROM test_me_i_am_broken WHERE (CHARINDEX(?, login_name) > 0 OR CHARINDEX(?, realname) > 0) AND disabledtext = ''",undef,$findme, $findme);
The Two parameters are being checked by the driver by issuing
set fmtonly on select 0,0 from test_me_i_am_broken where 1=2 set fmtonly off
The test for 0 seems to indicate that the driver is returning a int datatype instead of the actual datatype for parameter 1 of CHARINDEX.
I have worked with the maintainer for DBD::ODBC and from what we can tell this is a bug in the SQL Server Native Client 10.0 Driver.