Error - Attempting to set a non-NULL-able column's value to NULL

  • -- The error was caused by the following statement

    -- FieldE is an non-null field

    select FieldA, FieldB, FieldC

    from TableD

    where QuoteDate<GetDate() and Len(FieldE)=0

    -- the following statements gave no error

    -- no error

    select FieldA, FieldB, FieldC

    from TableD

    where QuoteDate<GetDate()

    -- no error

    select FieldA, FieldB, FieldC

    from TableD

    where QuoteDate<GetDate() and FieldF='test' and Len(FieldE)=0

    -- no error

    select FieldA, FieldB, FieldC

    from TableD

    where QuoteDate<GetDate() and FieldE=''

    I googled the error and found out that error is an known bug for SQL Server 2008. But what I read did not match the above description.

    I guess my SQL2008 R2 is not up to date. Where can I check the version of my SQL Server?

  • SELECT @@VERSION

    Cumulative Update # 6 is available for SQL Server 2008 R2

    http://support.microsoft.com/kb/2489376

    Regards,

    Syed Jahanzaib Bin Hassan

    MCTS | MCITP | OCA | OCP | OCE | SCJP | IBMCDBA

    My Blog

    http://www.aureus-salah.com

    Regards,
    Syed Jahanzaib Bin Hassan
    BSCS | MCTS | MCITP | OCA | OCP | OCE | SCJP | IBMCDBA

    My Blog
    www.aureus-salah.com

  • Can you post the actual error message, and the actual statement which causes it? The following works just fine on SP1:

    CREATE TABLE #TableD (FieldE VARCHAR(10) NOT NULL)

    INSERT INTO #TableD VALUES ('something')

    INSERT INTO #TableD VALUES ('')

    SELECT * FROM #TableD

    SELECT *

    FROM #TableD

    WHERE LEN(FieldE) = 0

    Also, what datatype is column FieldE?


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

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

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