title: SQL Server character set and N prefix
body: <p>[THIS IS <strong>NOT</strong> A QUESTION ABOUT <strong>NVARCHAR</strong> OR HOW TO STORE CHINESE CHARACTER]</p>
  
  <p>SQL Server 2008 Express</p>
  
  <p>Database collation is <code>SQL_Latin1_General_CP1_CI_AS</code></p>
  
  <pre><code>create table sample1(val varchar(2))
  insert into sample1 values(N'中文')
  </code></pre>
  
  <ol>
  <li>I know these Chinese characters would become junk characters.</li>
  <li>I know I can use nvarchar to overcome all problem.</li>
  </ol>
  
  <p>What I don't know is: why there isn't "string too long" error when I run the insert statement? </p>
  
  <ol>
  <li>N prefix means that client will encode the string using UNICODE. </li>
  <li>2 Chinese characters will become 4 bytes.</li>
  <li>varchar(2) can only contain 2 bytes.</li>
  </ol>
  
  <p>Why people down vote this question? really?</p>