简体   繁体   中英

SQL Server : “cannot insert the value NULL into column” but column is not null

I have a strange problem with a script that is performing some inserts into a SQL Server table. It has been working fine until today but now it fails every time, however no changes have been made to the code.

It returns the error

Cannot insert the value NULL into column 'IRS VAT Prod_ Posting Group', table 'NAV_2009_Test.dbo.TEST Pxx 2011$Interface Invoice'; column does not allow nulls.

As you can see, the [IRS VAT Prod_ Posting Group] column should be inserted with VAT - no column is null at all.

I tried changing the column to allow NULLS to see what would happen, but this made no difference.

This is my SQL statement :

INSERT INTO dbo.[TEST Pxx 2011$Interface Invoice] (
    [Entry Type],
    [Entry ID],
    [Reservation Contract],
    [Date],
    [Residential No_],
    [Gast Nr],
    Gastbezeichnung,
    [Moveware Customer No_],
    [Account No_],
    [Residential Cost Type],
    Description,
    Verrechnungsart,
    [Invoicing interval],
    Quantity,
    [Unit Price],
    Amount,
    [VAT Prod_ Posting Group],
    [Last Invoicing],
    [Next Invoicing],
    [Special Event],
    [Increase %],
    [Cost Unit],
    [Area Code],
    [From Date],
    [To Date],
    Address,
    [Post Code],
    City
)
VALUES
    (
        1,
        '590313',
        '1055',
        '2013-01-28',
        '',
        '1062',
        N'Jan Kling',
        '100127',
        '3030',
        '1',
        N'Sideboard ',
        '1',
        '1',
        '1',
        '17',
        '17',
        'VAT',
        '01-01-1753 00:00:00:000',
        '01-01-1753 00:00:00:000',
        '-',
        '0',
        '321',
        '',
        '2012-09-03',
        '2012-09-10',
        N'Zehnderweg 31',
        '4600',
        N'Olten'
);

As I said, no changes have been made to the code and so I am wondering if something could have gone awry on the server.

Can anyone shed any light?

The column IRS VAT Prod_ Posting Group is not mentioned at all in your insert query. It's likely that this column is NOT NULL and has no default value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM