>mi è partito 2 volte
>Messaggio 8152, livello 16, stato 14, riga 1
>I dati di tipo string o binary verrebbero troncati.
>L'istruzione è stata interrotta.
>qualcuno sa che errore è?
Ciao gommosina,
Questo errore si verifica quando tenti di "stipare" una stringa o un valore binario in una colonna troppo piccola per ospitare l'intero valore.
Osserva il seguente esempio:
USE tempdb;
CREATE TABLE dbo.Students(
StudentsID int NOT NULL,
FirstName varchar(7) NOT NULL
);
/* Questo inserimento andrà a buon fine */
INSERT dbo.Students VALUES(1, 'Lorenzo');
/* Questo no */
INSERT dbo.Students VALUES(2, 'gommosina');
/* Output:
Msg 8152, Level 16, State 14, Line 1
String or binary data would be truncated.
The statement has been terminated.
*/
/* Per permettere l'inserimento di 'gommosina'
** occorrerà ingrandire la colonna FirstName
*/
ALTER TABLE dbo.Students
ALTER COLUMN FirstName varchar(10) NOT NULL;
/* Ora 'gommosina' farà parte degli studenti :-) */
INSERT dbo.Students VALUES(2, 'gommosina');
SELECT *
FROM dbo.Students;
/* Output:
StudentsID FirstName
----------- ----------
1 Lorenzo
2 gommosina
(2 row(s) affected)
*/
/* Pulizia */
DROP TABLE dbo.Students;
>grazie
Prego.
Ciao!
--
Lorenzo Benaglia
Microsoft MVP - SQL Server
http://blogs.dotnethell.it/lorenzo/
http://italy.mvps.org