title: GUID in dynamic sql
body: <p>I am trying to use a column of type uniqueidentifier in Dynamic SQL.</p>
  
  <p>I have a table X, with column ID of type guid.</p>
  
  <p>If I do:</p>
  
  <pre><code>declare @primarykeyvalue varchar(50)  
  set @primarykeyvalue = '648D2DD7-0EB1-4E29-A996-69456753C460'  
  
  select * from X where ID = @primarykeyvalue
  </code></pre>
  
  <p>This works, but if I try to do the same in dynamic SQL like:</p>
  
  <pre><code>DECLARE @sql NVARCHAR(1000)   
  SET @sql = 'select * from X where ID = ' + @primarykeyvalue  
  EXECUTE(@sql)
  </code></pre>
  
  <p>This gives an syntax error as Incorrect syntax near 'D2DD7'.</p>
  
  <p>Any suggestions please?</p>