This is the format of the code I am trying to run;
DECLARE @QUERY NVARCHAR(MAX)=\'SELECT * FROM MyQuery\' EXEC sp_execute_external_script @language = N\'R\'