title: How to make SqlContext.Pipe.Send in SQLCLR stored proc work with unicode?
body: <p>I'm having problems with SQL CLR integration with unicode (Hebrew and Russian text). As a test, I made a simple database project in Visual Studio with the following CLR stored procedure:</p>
  
  <pre class="lang-cs prettyprint-override"><code>[Microsoft.SqlServer.Server.SqlProcedure]
  public static void TestProc ()
  {
      //Console.OutputEncoding = System.Text.Encoding.Unicode;
      Trace.WriteLine("Unicode test: blip");
      Trace.WriteLine("Unicode test: בליפ");
      Trace.WriteLine("Unicode test: Блип");
      SqlContext.Pipe.Send("Unicode test: blip");
      SqlContext.Pipe.Send("Unicode test: בליפ");
      SqlContext.Pipe.Send("Unicode test: Блип");
  }
  </code></pre>
  
  <p>Published to a test database and executed the stored procedure in SQL server:</p>
  
  <pre class="lang-sql prettyprint-override"><code>EXEC dbo.TestProc;
  </code></pre>
  
  <p>Both the trace output and SQL server messages replace non-English characters with '????'.</p>
  
  <p>I thought both SQL server and C# worked with unicode. Working with unicode in a Windows Forms project, for example by adding non-English text to a textbox, works fine.</p>
  
  <p>How can I fix this? Is there some setting I'm missing?</p>
  
  <p>This Question relates to the following: <a href="https://stackoverflow.com/questions/36915616/how-to-pass-nvarchar-non-english-to-clr-c-stored-procedure">How to pass nvarchar (non-English) to CLR (C#) stored procedure?</a></p>