title: SQL Server: converting UniqueIdentifier to string in a case statement
body: <p>We have a log table that has a message column that sometimes has an exception stack trace. I have some criteria that determines if the message has this. We do not want to show these messages to the customer but instead have a message like:</p>
  
  <blockquote>
    <p>Internal Error Occured. Contact US
    with reference code
    xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</p>
  </blockquote>
  
  <p>where xxx etc is a guid column in the table. I am writing stored proc like this:</p>
  
  <pre><code>declare @exceptionCriteria nvarchar(50)
  select @exceptionCriteria = '%&lt;enter criteria etc&gt;%'
  
  select LogDate,
         case
         when Message like @exceptionCriteria
         then 'Internal Error Occured. Reference Code: ' + str(RequestID)
         else Message
         end
    from UpdateQueue
  </code></pre>
  
  <p><code>RequestID</code> is a Guid datatype in SQL Server and does not convert to string here. I've seen some code on how to convert a Guid to string, but it is multi-lined and I don't think it would work in a case statement. Any ideas?</p>