How to treat plus sign from user input as part of input string and not as concat operator?
<p>This is for a small internal tool to enable a few people to query the database. The query has a plus sign as below:</p>

<pre><code>SELECT SUBSTRING(DateName(month,CreatedOn),0,4) + ' - ' + SUBSTRING(CAST(Year(CreatedOn) AS varchar(10)),3,3) as Month, Year(CreatedOn) as Year,
</code></pre>

<p>The query is passed to the server using a jquery ajax call </p>

<pre><code> var d = "query=" + $("#txtQuery").val();
            $.ajax({
                type: 'GET',
                url: '/Reports/GetReport',
                data: d,
</code></pre>

<p>However, I get a server error and debugging I find that the query on the server is missing the plus sign. i.e.</p>

<pre><code> SELECT SUBSTRING(DateName(month,CreatedOn),0,4)  ' - '  SUBSTRING(CAST(Year(CreatedOn) AS varchar(10)),3,3) as Month
</code></pre>

<p>And from FireBug,</p>

<pre><code>localhost:1489/Reports/GetReport?query=SELECT%20SUBSTRING(DateName(month,CreatedOn),0,4)%20+%20%27%20-%20%27%20+%20SUBSTRING(CAST(Year(CreatedOn)%20AS%20varchar(10)),3,3)%20as%20Month,%20Year(CreatedOn)%20as%20Year..
</code></pre>

<p>How do I ensure that the plus is treated as a part of the input string and not as a concat operator which seems to be the case here. </p>
