Torna al Thread
USE tempdb;
CREATE TABLE dbo.Studenti(
CodiceFiscale char(16) NOT NULL,
Nome varchar(10) NOT NULL,
Cognome varchar(10) NOT NULL,
CONSTRAINT PK_Studenti PRIMARY KEY (CodiceFiscale)
);
INSERT dbo.Studenti VALUES('BNGLNZ71H12M052S', 'Lorenzo', 'Benaglia');
/* Output:
(1 row(s) affected)
*/
INSERT dbo.Studenti VALUES('BNGLNZ71H12M052S', 'Lorenzo', 'Benaglia');
/* Output:
Msg 2627, Level 14, State 1, Line 1
Violation of PRIMARY KEY constraint 'PK_Studenti'. Cannot insert duplicate key in object 'dbo.Studenti'.
The statement has been terminated.
*/
SELECT *
FROM dbo.Studenti;
/* Output:
CodiceFiscale Nome Cognome
---------------- ---------- ----------
BNGLNZ71H12M052S Lorenzo Benaglia
(1 row(s) affected)
*/
DROP TABLE dbo.Studenti;