One of our applications report on error message 2628:
string or binary data would be truncated in table '******', column '******'. Truncated value: '******'
instead of
String or binary data would be truncated in table 'mytable', column 'mycolumn'. Truncated value: 'myvalue'.
which I get with SSMS.
What setting do I need to change to get the full message?
I've tried to search for this, but all I get is that I need to set VERBOSE_TRUNCATION_WARNINGS to ON and compatibility_level to 150. Which I've done ages ago.
The application has this error handler:
try { ES.isWorking = true; Worker worker = new Worker(new DBConnection(Settings.ConnectionString)); worker.DoWork(); ES.isWorking = false; } catch (Exception ex) { ES.isWorking = false; this.eventLog.WriteEntry("In OnTimer exception ! message: " + ex.Message.ToString()); errorHandler.HandleException(ex, "In OnTimer exception !", ErrorSeverities.Error); } The errorHandler looks like this
Public Function HandleException(ByVal incommingEx As System.Exception, ByVal note As String, ByVal errorSeverity As ErrorSeverities, Optional ByVal sessionId As String = "", Optional ByVal applicationSource As String = "", Optional ByVal ignoreDB As Boolean = False, Optional ByVal noMail As Boolean = False) As Integer Dim stackTraceBuilder As New System.Text.StringBuilder Dim targetSite As String = "" Dim errorTime As DateTime = Now Dim messageBuilder As New System.Text.StringBuilder Dim innerEx As Exception = incommingEx.InnerException Dim errorId As Integer = 0 Dim innerCount As Integer = 1 Dim loggedToDb As Boolean = False Dim appSource As String = Me._applicationSource If applicationSource <> "" Then appSource = applicationSource End If '... more code' messageBuilder.AppendLine("(" + incommingEx.GetType.Name.ToUpper + ")" + vbCrLf + incommingEx.Message + " - SOURCE: " + incommingEx.Source) '...' While Not innerEx Is Nothing And innerCount <= 5 messageBuilder.AppendLine("INNER" + Convert.ToString(innerCount) + " (" + innerEx.GetType.Name.ToUpper + "):" + vbCrLf + **innerEx.Message** + " - SOURCE: " + innerEx.Source) If Not innerEx Is Nothing AndAlso Not innerEx.StackTrace Is Nothing Then stackTraceBuilder.AppendLine("INNER" + Convert.ToString(innerCount) + ": " + innerEx.StackTrace) 'Me.GetNumberedStack(innerEx)) End If innerEx = innerEx.InnerException innerCount += 1 End While '... more code where the error message is inserted in a log table, via a sproc' End Function We have not seen this behavior before, but we have recently updated the .net framework to version 4.7.2, so it could be related.
the error text "string or binary" is comming from the bit that goes
- innerEx.Message + and that is a simple built-in Exception data type. So it is VB and/or .net and/or SQL Server that is building the string, not us.
The error comes after a call to a stored procedure, where the user has probably entered a varchar(1000) text. The stored procedure adds a bit more, and the table hasn't got room for all 1100 bytes. Hence the error. The stored procedure does not have a try-catch block.
