title: Text is being truncated on Insert into SQL Server database
body: <p>We have a strange problem using <code>SqlCommand</code> to insert data into a SQL Server database. If we try to insert a large text into the column <code>konnotiz1</code>, the text is being truncated after 43245 characters. For some reason I don't understand the real application code creates 42909 characters. </p>
  
  <p>Here's a screenshot of the column properties page:</p>
  
  <p><img src="https://i.stack.imgur.com/DfJuT.png" alt="SQL-Server Management Studio propertypage"></p>
  
  <p>The following code causes the problem:</p>
  
  <pre><code>static void Test()
  {
      using (System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(getConString()))
      {
          con.Open();
          System.Data.SqlClient.SqlCommand cmd = con.CreateCommand();
          cmd.CommandText = "Insert into kontakte (konlfdnr, konNotiz1) values (@konlfdnr, @konNotiz1)";
          cmd.CommandType = CommandType.Text;
          cmd.CommandTimeout = 60;
  
          // you can ignore this param, it's owner pk-column. 
          System.Data.SqlClient.SqlParameter param = cmd.Parameters.Add("@konlfdnr", SqlDbType.Char, 10);
  
          // better don't ask why we have to pad this... ;) 
          param.Value = "1".PadLeft(10);
          param.Direction = ParameterDirection.Input;
  
          param = cmd.Parameters.Add("@konNotiz1", SqlDbType.Text);
          param.Direction = ParameterDirection.Input;
          param.Value = getParamValue();
  
          cmd.ExecuteNonQuery();
          con.Close();
      }
  }
  
  private static string getParamValue()
  {
       // my Textfile has something about 300000 characters. It's a html code from a mail.
       return System.IO.File.ReadAllText("C:\\Temp\\insert.txt");
  }
  
  private static string getConString()
  { 
      return @"Data Source=NB-JH1\SQLEXPRESS;Initial Catalog=Testsystem_Local;Integrated Security=True;Encrypt=True;TrustServerCertificate=True;Pooling=True;MultipleActiveResultSets=True;
  }
  </code></pre>
  
  <p>Has anyone an idea, why the text is being truncated and how we can get this working?</p>