Bug fixes for SQL queries against Sybase