Index: Adapter/Sqlsrv.php =================================================================== --- Adapter/Sqlsrv.php (revision 21196) +++ Adapter/Sqlsrv.php (working copy) @@ -314,7 +314,7 @@ return sprintf('%F', $value); } - return "'" . str_replace("'", "''", $value) . "'"; + return "N'" . str_replace("'", "''", $value) . "'"; } /** Index: Statement.php =================================================================== --- Statement.php (revision 21196) +++ Statement.php (working copy) @@ -190,21 +190,23 @@ // get the character for value quoting // this should be ' $q = $this->_adapter->quote('a'); - $q = $q[0]; + preg_match('/^(.*)a(.*)$/', $q, $matches); + $qStart = $matches[1]; + $qEnd = $matches[2]; // get the value used as an escaped quote, // e.g. \' or '' - $qe = $this->_adapter->quote($q); - $qe = substr($qe, 1, 2); + $qe = $this->_adapter->quote($qEnd); + $qe = substr($qe, strlen($qStart), (-1)*strlen($qEnd)); $qe = str_replace('\\', '\\\\', $qe); // get a version of the SQL statement with all quoted // values and delimited identifiers stripped out // remove "foo\"bar" - $sql = preg_replace("/$q($qe|\\\\{2}|[^$q])*$q/", '', $sql); + $sql = preg_replace("/$qStart($qe|\\\\{2}|[^$qEnd])*$qEnd/", '', $sql); // remove 'foo\'bar' if (!empty($q)) { - $sql = preg_replace("/$q($qe|[^$q])*$q/", '', $sql); + $sql = preg_replace("/$qStart($qe|[^$qEnd])*$qEnd/", '', $sql); } return $sql;