String or Binary data error would be truncated - SQL

Asked

Viewed 1,278 times

2

This is the structure of my table;

CREATE TABLE Pessoaldesenv.dbo.Conformidade (
    [ID numeric] numeric(19,0) IDENTITY(1,1) NOT NULL,
    Validacao int NULL,
    Arquivo varchar(100) COLLATE SQL_Latin1_General_CP1_CI_AI NULL,
    CodigoAudinUJ varchar(6) COLLATE SQL_Latin1_General_CP1_CI_AI NOT NULL,
    Remessa numeric(19,0) NULL,
    ChaveRegistro varchar(MAX) COLLATE SQL_Latin1_General_CP1_CI_AI NULL,
    NaoConformidade varchar(MAX) COLLATE SQL_Latin1_General_CP1_CI_AI NULL,
    Detalhe varchar(MAX) COLLATE SQL_Latin1_General_CP1_CI_AI NULL,
    Reincidencia int NULL,
    FalsoPositivo numeric(1,0) DEFAULT 0 NULL,
    Resolvida int NULL,
    Observacao varchar(MAX) COLLATE SQL_Latin1_General_CP1_CI_AI NULL,
    DataEntrada date NULL,
    DataFalsoPositivo date NULL,
    CONSTRAINT PK__NaoConfo__ADCA4E927FFBBC86 PRIMARY KEY ([ID numeric])
) GO;

This is the Insert I’m doing on the table;

INSERT INTO Pessoaldesenv.dbo.Conformidade
(
Validacao, 
Arquivo, 
CodigoAudinUJ, 
Remessa, 
ChaveRegistro, 
NaoConformidade, 
Detalhe, 
Reincidencia, 
FalsoPositivo, 
Resolvida, 
Observacao, 
DataEntrada, 
DataFalsoPositivo)
VALUES(
1, 
'ARQUIVO1',
'CodigoAudinUJ', 
0, 
'CHAVE_REGISTRO1',  
'NAO CONFORMIDADE1', 
'', 
0, 
0, 
0, 
'', 
'2004-07-12', 
'2004-07-12'
);

I am using SQL serves, why is giving the error of String or Binary data would be truncated ?

2 answers

3


This error usually occurs when trying to insert a string bigger than the field can handle.

Ex: Codigoaudinuj varchar(6) If you insert a string with 7 characters or more, will give error. In the case, CodigoAudinUJ.

2

You are trying to add a higher value than the column allows.

Your column CodigoAudinUJ has size 6 and you are trying to insert 13 characters.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.