Errore sql

giovedì 16 ottobre 2008 - 22.03

gommosina Profilo | Junior Member

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 è?grazie

lbenaglia Profilo | Guru

>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

gommosina Profilo | Junior Member

grazie mille, gentilissimo..non ci sarei mai arrivata
grazie ancora
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5