Column set to varchar(max) error

  • I have some code that logs validation messages that are displayed to users of our software. The table it is saved in is comprised of 5 columns  
    Record identity column,
    UserID char(9),
    ValidationMessage varchar(max),
    DataSubmitted varchar(max),
    InstanceDate datetime

    The information is input via the following sproc

    CREATE PROCEDURE [dbo].[LogValidationMessage]

    @user-id char(9),
    @ValidationMessage varchar(max),
    @DataSubmitted varchar(max)

    AS

    SET NOCOUNT ON

    INSERT INTO
        dbo.ValidationLog
    VALUES
    (
        @UserID,
        @ValidationMessage,
        @DataSubmitted,
        GETDATE()
    )

    I receive emails every time a 500 error occurs on the web server and yesterday I received the following message

    [Microsoft][ODBC SQLServer Driver]String data, right truncation

    Not knowing what the user is neglecting to fill out I have no idea what the ValidationMessage or the DataSubmitted will be which is why I set them to varchar(max) so why is it giving that error?

  • mjohnson 71479 - Wednesday, March 21, 2018 10:25 AM

    I have some code that logs validation messages that are displayed to users of our software. The table it is saved in is comprised of 5 columns  
    Record identity column,
    UserID char(9),
    ValidationMessage varchar(max),
    DataSubmitted varchar(max),
    InstanceDate datetime

    The information is input via the following sproc

    CREATE PROCEDURE [dbo].[LogValidationMessage]

    @user-id char(9),
    @ValidationMessage varchar(max),
    @DataSubmitted varchar(max)

    AS

    SET NOCOUNT ON

    INSERT INTO
        dbo.ValidationLog
    VALUES
    (
        @UserID,
        @ValidationMessage,
        @DataSubmitted,
        GETDATE()
    )

    I receive emails every time a 500 error occurs on the web server and yesterday I received the following message

    [Microsoft][ODBC SQLServer Driver]String data, right truncation

    Not knowing what the user is neglecting to fill out I have no idea what the ValidationMessage or the DataSubmitted will be which is why I set them to varchar(max) so why is it giving that error?

    Quick question, have you checked the UserID, seems like a likely culprit to me?
    😎
    Can you post the DDL for dbo.ValidationLog?
    The capacity of VARCHAR(MAX) is roughly 2147483640 characters, unlikely that it would be exceeded by a user input.
    Another possibility is that the destination table does not have VARCHAR(MAX) but something less.

  • I receive emails every time a 500 error occurs on the web server and yesterday I received the following message
    [Microsoft][ODBC SQLServer Driver]String data, right truncation[Microsoft][ODBC SQLServer Driver]String data, right truncation  
    Not knowing what the user is neglecting to fill out I have no idea what the ValidationMessage or the DataSubmitted will be which is why I set them to varchar(max) so why is it giving that error?

    Just my assumption,  Would it be some character(s) that belongs to an international language??  May need nvarchar datatype.🙁

    =======================================================================

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply