title: Php pdo_dblib sql server pagination
body: <p>I can execute query like this against sql server:</p>
  
  <pre><code>DECLARE @ROWS INT = 2, @PAGE INT = 2
  SELECT *
  FROM (
      SELECT *,
      ROW_NUMBER() OVER (ORDER BY ID) AS _NO
      FROM [Reports].[dbo].[Cycle] 
  ) AS SOD
  WHERE SOD._NO BETWEEN ((@PAGE-1)*@ROWS)+1
  AND @ROWS*(@PAGE)
  GO
  </code></pre>
  
  <p>and i got result:</p>
  
  <p><img src="https://i.stack.imgur.com/7q1z8.jpg" alt="result of executing query"></p>
  
  <p>but if i try to do so in pdo through dblib it doesn't work:</p>
  
  <pre><code>            $stmt = $pdo-&gt;query("
      DECLARE @ROWS INT = 2, @PAGE INT = 2
      SELECT *
      FROM (
          SELECT *,
          ROW_NUMBER() OVER (ORDER BY ID) AS _NO
          FROM [Reports].[dbo].[Cycle] 
      ) AS SOD
      WHERE SOD._NO BETWEEN ((@PAGE-1)*@ROWS)+1
      AND @ROWS*(@PAGE)
      GO
      ");
  
              var_dump($stmt-&gt;fetchAll(PDO::FETCH_ASSOC));
  </code></pre>
  
  <p>error code:</p>
  
  <pre><code>PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 102 General SQL Server error: Check messages from the SQL Server [102] (severity 15)
  </code></pre>
  
  <p>description of error according error mesages: <a href="http://www.sql-server-helper.com/error-messages/msg-1-500.aspx" rel="nofollow noreferrer">http://www.sql-server-helper.com/error-messages/msg-1-500.aspx</a></p>
  
  <p>is: </p>
  
  <pre><code>Incorrect syntax near '%.*ls'.
  </code></pre>