title: Query for R Machine Learning Services - Filtering Categories in Where Clause
body: <p>I am trying to run a query in SQL Server using the Machine Learning Services extension.</p>
  <p>So this is the problem I am having;</p>
  <pre><code>DECLARE @query NVARCHAR(MAX) = '
  SELECT CATEGORY1,CATEGORY2
  FROM TABLE
  WHERE CATEGORY1 = 'A'
  AND CATEGORY2 = 'B'
  '
  EXEC sp_execute_external_script @language = N'R',
  @script = N'data &lt;- Rscript'
  ,@input_data_1 = @query
  ,@input_data_1_name= N'data'
  </code></pre>
  <p>You see I am creating a variable with a string value, which is the SQL Query. This query is then passed into the stored procedure that runs R in SQL Server. The problem is the WHERE clause in the query. I have string values specified and it breaks the query because now I have Apostrophes within Apostrophes.</p>
  <p>I have tried to replace the apostrophes with different characters, but I cannot get this to work. Is establishing string values in the query possible in this fashion?</p>