title: Error parsing query in SQL Server Compact
body: <p>I am running my query using WebMatrix, I think it is correct, however I am getting an error.</p>
  
  <p>My query is as follows :</p>
  
  <pre><code>   var result = db.Query(
                  @"SELECT e.event_id, e.title, e.description, e.event_start, e.event_end, e.group_id, e.recurring
                  FROM   event e
                  JOIN   Membership m ON m.GroupID = e.group_id
                  WHERE  e.recurring = 0
                  AND    m.UserID = @0
                  AND    e.event_start &gt;= @1
                  AND    e.event_end &lt;= @2
                  UNION ALL
                  SELECT e.event_id, e.title, e.description, DATEADD(week, w.weeks, e.event_start), DATEADD(week, w.weeks, e.event_end), e.group_id, e.recurring
                  FROM   event e
                 JOIN   Membership m ON m.GroupID = e.group_id
                 CROSS JOIN 
                  ( SELECT  row_number() OVER (ORDER BY Object_ID) AS weeks
                    FROM SYS.OBJECTS
                  ) AS w
                  WHERE  e.recurring = 1
                  AND    m.user_id = 4;
                  AND    e.event_start &gt;= @4
                  AND    e.event_end &lt;= @5", userID, start, end, userID, start, end
              );
  </code></pre>
  
  <p>The error is :</p>
  
  <blockquote>
    <p>System.Data.SqlServerCe.SqlCeException (0x80004005): There was an
    error parsing the query. [ Token line number = 10,Token line offset =
    38,Token in error = OVER ]    at
    System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr)    at
    System.Data.SqlServerCe.SqlCeCommand.CompileQueryPlan()</p>
  </blockquote>
  
  <p>I'm holding query in a .cs file. I'm told I should create a stored procedure since SQL Server compact may not support the OVER function, is this correct? How can I create a stored procedure for this query?</p>