title: Writing Japanese string to a text file through SQL query
body: <p>I have a requirement where i need to write Japanese strings stored in a table to a text file.
  I tried below query, its printing only question marks in text file.</p>
  
  <pre><code>DECLARE @cmd NVARCHAR(2000), @Msg NVARCHAR(1000);
  SELECT @Msg=String FROM JapaneseStringTable;
  SET @cmd='echo '+@Msg+'&gt;&gt;'+'C:\Data\Test.txt';
  EXEC sys.xp_cmdshell @cmd;
  </code></pre>
  
  <p>I tried to hard code the Japanese string and write to file, still no luck</p>
  
  <pre><code>DECLARE @cmd NVARCHAR(2000),
  @Msg NVARCHAR(1000)=N'データノード';
  SET @cmd='echo '+@Msg+'&gt;&gt;'+'C:\Data\Test.txt';
  EXEC sys.xp_cmdshell @cmd;  
  </code></pre>