I transfer from MYSQL in MSSQL the project. Faced a problem in the prepared requests. If earlier I used in MYSQL
$stmt = $db->prepare("SELECT 1 as something, t.id, creator_id, status, fire, u.firstname as firstname, u.surname as surname, category, responsible, t.dept, FROM tickets as t LEFT OUTER JOIN users as u ON t.responsible = u.id WHERE creator_id = :uid AND status = 'Статус 1' UNION SELECT 2 as something, t.id, creator_id, status, fire, u.firstname as firstname, u.surname as surname, category, responsible, t.dept, FROM tickets as t LEFT OUTER JOIN users as u ON t.responsible = u.id WHERE creator_id = :uid AND (status = 'Статус 2' OR status = 'Статус 3' OR status = 'Статус 4') "); $ stmt-> bindParam (': uid', $ uid, PDO :: PARAM_INT);
All was good.
But in a situation with MSSQL, only the usual query is processed if you substitute values manually, and when prepare, an error is thrown: [Microsoft] [ODBC Driver 11 for SQL Server] COUNT
* Moreover, I noticed that if you do not use UNION, then there are no errors. I leave only the first SELECT and there are no errors.
I would be glad if anyone has experience how to get around such an unpleasant thing.