title: SQL Server inserts a special string (space on the right) and exceeds the column size. Why not report an error?
body: <p>DB version：SQL Server 2016</p>
  <pre><code>--Create database
  CREATE TABLE [dbo].[test] ([a] nvarchar(3))
  
  --Insert strings longer than 3 （Success and not report an error）
  SET ANSI_PADDING ON;
  
  INSERT INTO test VALUES('1            ');
  
  --Query table results '1  ',Its length is 3.
  
  SET ANSI_PADDING ON;
  
  INSERT INTO test VALUES('1111111111');
  --[Err] 22001 - [SQL Server]String or binary data would be truncated.
  </code></pre>
  <p>According to <a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/set-ansi-padding-transact-sql?view=sql-server-2016" rel="nofollow noreferrer">docs.microsoft.com</a>, said &quot;Trailing blanks in character values inserted into varchar columns are not trimmed.&quot;</p>
  <p>Who can tell me why? Thanks a lot!</p>