Finalmente... "String or binary data would be truncated"

Finalmente.. 

Questo รจ quello che mi sono detto mentre leggevo le novitร  che l'uscita della Versione 2019 di SQL Server si porterร  dietro.

Sicuramente, tutti coloro che per lavoro o anche solo per semplice hobby, usano SQL Server si saranno piรน e piรน volte imbattuti in questo errore:

       
Msg 8152, Level 16, State 30, Line 3
String or binary data would be truncated.
The statement has been terminated     
 
La reazione a questo errore รจ sempre e solo una:

OK sto inserendo i dati in una tabella, sto scrivendo un testo troppo lungo rispetto alla dimensione di una colonna e mi esce l'errore.
Ma quale sarร  questa colonna che causa l'errore?
Adesso dovrรฒ iniziare a controllarle una ad una..

Bene! La novitร  รจ che SQL Server 2019 ci dirร  qual'รจ la colonna in cui stiamo cercando di inserire un testo troppo lungo:

       
Msg 2628, Level 16, State 1, Line 3
String or binary data would be truncated in table 'Demo.dbo.MyTable'.
column 'MyColumn'. Truncated value: 'My D'.       
 
Finalmente potremo risparmiare un bel po di tempo!

Questa nuova feature รจ stata resa disponibile a partire dalla CTP 2.1 anche se solo dietro attivazione della trace flag 460.
Si spera perรฒ che con l'uscita della versione definitiva questa utile novitร  diventi attiva "by default"

Per oggi รจ tutto! Alla prossimo post!

Luca Biondi @ SQLServerPerformance blog!

 






Next post: Cos’รจ il database TEMPDB? ...e quindi perchรฉ รจ importante.

Previous post:

Comments

I Post piรน popolari

Speaking to Sql Server, sniffing the TDS protocol

SQL Server, find text in a Trigger, Stored Procedures, View and Function. Two ways and what ways is better

SQL Server, Avoid that damn Table Spool!