title: Convert a MSSQL String to Hex and unhex the value in MySQL
body: <p>I want to convert a string in Microsoft SQL to hexdecimal value, for example this:</p>
  
  <pre><code>declare @b varbinary(max)
  set @b = (Select cast('Ali' as varbinary))
  
  select cast(@b as varchar(max))
  select @b
  </code></pre>
  
  <p>It returns:</p>
  
  <p><img src="https://i.stack.imgur.com/nU4Td.gif" alt=""></p>
  
  <p>This is great! But know I want to unhex the exact string in MySQL:</p>
  
  <p><img src="https://i.stack.imgur.com/SquSu.gif" alt=""></p>
  
  <p>So in MySQL the string looks a bit different from the string I get from MSSQL. Maybe I could do a string replace or something</p>
  
  <p><strong>But with a more complex string it even varys between mssql and mysql:</strong></p>
  
  <p>-- Same procedure as before, just tried another string: --</p>
  
  <p><img src="https://i.stack.imgur.com/8Vwlq.gif" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/VvSzk.gif" alt="enter image description here"></p>
  
  <pre><code>MSSQL-String: 0x53414D31302F32303130E4F6FCDF5C2A23E92D656E64657C3C6469762073
  MySQL-String:   53414D31302F32303130C3A4C3B6C3BCC39F2A23C3A92D656E
  </code></pre>
  
  <p>The beginning is the same (maybe because of the SAM), but it seems to be a problem with the special chars ... :-(</p>