title: Incorrect syntax near ')' in SQL Server
body: <p>I am getting an error:</p>
  
  <blockquote>
    <p>Incorrect syntax near ')' </p>
  </blockquote>
  
  <p>while trying to run the SQL query shown below on SAP Business Objects Information design tool. The query executes just fine from SQL Server, but from SAP Information design tool, I get this incorrect syntax error while trying to see the table values.</p>
  
  <p>SQL Error:</p>
  
  <p><img src="https://i.stack.imgur.com/6vRGv.png" alt="SQL Error"></p>
  
  <p>Valid SQL</p>
  
  <p><img src="https://i.stack.imgur.com/36p90.png" alt="Valid SQL"></p>
  
  <pre><code>;WITH XMLNAMESPACES('Callaway.CRM.DAL.Objects.VisitActivityDetail' as ns)
  SELECT 
      r.value('(ns:*)[3]','nvarchar(1000)') AS VisitType
  FROM 
      Activity
  OUTER APPLY 
      XML.nodes('/ns:VisitActivityDetail/ns:VisitType') AS x(r)
  WHERE
      ActivityTypeID = 2
  </code></pre>
  
  <p>Can you please help me understand what is wrong here?</p>