title: Can double quotes be used to delimit a string?
body: <p>I was surprised to encounter a SQL 2008 T-SQL proc that used a double quote as a string delimiter. For example:</p>
  
  <pre><code>DECLARE @SqlStmt AS VarChar(5000)
  SET @SqlStmt = "ok"
  PRINT @SqlStmt
  </code></pre>
  
  <p>I didn't think it was allowed. I thought only apostrophes could be used.</p>
  
  <p>Thinking that T-SQL is flexible like Javascript to allow either as delimiters in case you wanted to mix the two in a single statement, I tried to do the same in one of my stored procs because I wanted to construct dynamic SQL that included ticks.  I was surprised that the script wouldn't compile, I was getting an "INVALID COLUMN [X]" error where X was the contents of my quoted string.</p>
  
  <p>So, I stripped it down to it simplest components until I got the exact SQL you see above, which compiles, runs, and prints "OK".</p>
  
  <p>Now the real surprising part:</p>
  
  <p>I placed the T-SQL script above on my clipboard, executed Control + N to open a new query window using the same connection and pasted the above script into the new query window and was shocked to see that I was getting the following error in the new window:</p>
  
  <pre><code>Msg 207, Level 16, State 1, Line 3
  Invalid column name 'ok'.
  </code></pre>
  
  <p>Explanation Update:</p>
  
  <p>Apparently I had removed the SET QUOTED_IDENTIFIER from the original script, but I had already executed it in the original query window, but the option was still in effect. When I created a new query Window, the option was reset to off by default.</p>
  
  <p>Thanks for the answers.</p>