Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

SQLException due to too long value. But MaxLength not exceeded

Posted on by 10
Hey,

While creating a lead, I get a weird Exception.
As soon as the subject field exceeds 51 chars a SQLException is thrown. But in CRM the maximum length of this field is set to 300 chars.

Has anyone an idea?

System: CRM-Online
Early/latebound: Earlybound


{Exception details: ErrorCode: 0x80073001 Message: Sql error: A validation error occurred. A string value provided is too long. CRM ErrorCode: -2147012607 Sql ErrorCode: -2146232060 Sql Number: 8152 TimeStamp: 2019-06-17T09:54:28.1568230Z -- Exception details: ErrorCode: 0x80073001 Message: Sql error: A validation error occurred. A string value provided is too long. CRM ErrorCode: -2147012607 Sql ErrorCode: -2146232060 Sql Number: 8152 TimeStamp: 2019-06-17T09:54:28.1568230Z -- Exception details: ErrorCode: 0x80073001 Message: Sql error: A validation error occurred. A string value provided is too long. CRM ErrorCode: -2147012607 Sql ErrorCode: -2146232060 Sql Number: 8152 TimeStamp: 2019-06-17T09:54:28.1568230Z -- Exception details: ErrorCode: 0x80040216 Message: Exception output:: System.Data.SqlClient.SqlException (0x80131904): String or binary data would be truncated. The statement has been terminated. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Microsoft.Crm.CrmDbConnection.LockConnectionAndExecuteMethod[TResult](IDbConnection connection, Func`1 executeMethod) at Microsoft.Crm.CrmDbConnection.InternalExecuteWithRetry[TResult](Func`1 ExecuteMethod, IDbCommand command, ICrmTransaction crmTransaction) at Microsoft.Crm.CrmDbConnection.<>c__DisplayClass122_0.<InternalExecuteNonQuery>b__0() at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties) at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func) at Microsoft.Crm.Platform.Server.DataEngine.SqlDataAccessManager.ExecuteNonQuery(IDbCommand command, ISqlExecutionContext context, Int32 sourceLineNumber, String memberName, String sourceFilePath) at Microsoft.Crm.Platform.Server.DataEngine.EntityCrudManager.Create(IBusinessEntity entity, ExecutionContext context) at Microsoft.Crm.BusinessEntities.BusinessProcessObject.DoCreate(IBusinessEntity entity, ExecutionContext context) ClientConnectionId:419f89ff-ca05-4488-82f1-b3fd286dbb7c Error Number:8152,State:13,Class:16 ClientConnectionId before routing:dc443f59-ff1a-44ed-b79c-078a9fce65bf Routing Destination:e6c362a837bc.tr641.northeurope1-a.worker.database.windows.net,11042 Error(s) details: Class: 0x10 LineNumber: 1 Message: String or binary data would be truncated. Number: 8152 Procedure: Server: e6c362a837bc.tr641.northeurope1-a.worker.database.windows.net,11042 Source: .Net SqlClient Data Provider State: 13 ToString(): System.Data.SqlClient.SqlError: String or binary data would be truncated. -- Class: 0x0 LineNumber: 1 Message: The statement has been terminated. Number: 3621 Procedure: Server: e6c362a837bc.tr641.northeurope1-a.worker.database.windows.net,11042 Source: .Net SqlClient Data Provider State: 0 ToString(): System.Data.SqlClient.SqlError: The statement has been terminated. -- : Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #F01E7DEE TimeStamp: 2019-06-17T09:54:28.1568230Z -- }


*This post is locked for comments

  • andzie Profile Picture
    andzie 10 on at
    RE: SQLException due to too long value. But MaxLength not exceeded

    Thank you very much for your help!

    Somehow the FirstName of the lead is set to the subject name, if it is null during create.

    Regards

    Andreas

  • Verified answer
    Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: SQLException due to too long value. But MaxLength not exceeded

    Hi

    The 50 chars limit is for names fields like First Name, Last Name, and Middle Name. Make sure you are not setting longer values to these fields.

    The error message does not have the details on which field exceeded the limit.

    I would enable plugin trace log in CRM and see if you could find more error details around to see which field the error is referring to.

    If the plugin trace log does not have any meaningful message, I would check if there are any processes in CRM plugin / real-time workflow that copies lead the subject into any other field that has a max limit set to 50 chars.

    In your client side code, try setting value only to subject field and leave all other blank and try to create and see if it fails to rule out it's not caused by you setting the longer value to other fields.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans