2
I have the variable @numero1
which brings the following result:
020000000000720000018
But at the time of update gives error:
SQL Server String or Binary data would be truncated
declare @g1 varchar(50)
declare @numero1 varchar(50)
set @g1 = SUBSTRING(@vNossoNumero, 1, 2) + REPLICATE('0', 9) +
SUBSTRING(@vNossoNumero, 3, LEN(@vNossoNumero))
set @numero1 = left(@g1,Max(LEN(@g1))-2)
print @numero1 // - dá erro nessa variável
update DUPLICATA set DupNossoNumBco=@numero1 where DupNum=(
select ParcDocFinDupNum from PARC_DOC_FIN
where EMPCOD = @EMPCOD
AND DOCFINCHV = @DOCFINCHV
AND PARCDOCFINSEQ = @PARCDOCFINSEQ
AND PARCDOCFINDESMPAG = @PARCDOCFINDESMPAG
)
END
This error is related to the size of
varchar
you will receive the update. You can ask the question the size of the fieldDupNossoNumBco
?– Pagotti
It has the size 20
– Felipe Michael da Fonseca
So you already found the answer. Your variable has a 21-character content. =)
– Pagotti
Something strange/curious is the use of max()
– José Diz
The result of the variable
@numero1
turns out to be 28, so trying to update a field of size 20 with 28 characters gives error.– João Martins