-6

I have a database called Music and a table called Genre. I have written the following code:

USE Music

INSERT INTO Genre (GenreID, Genre)
VALUES 
  (1,'Rock'),
  (2,'Jazz'), 
  (3,'Country'),
  (4,'Pop'),
  (5,'Blues'),
  (6,'Hip-Hop'),
  (7,'Rap'),
  (8,'Punk');

I am getting the following error:

Msg 544, Level 16, State 1, Line 3
Cannot insert explicit value for identity column in table 'Genre' when IDENTITY_INSERT is set to OFF.

Any ideas why this is?

Larnu
  • 76,706
  • 10
  • 34
  • 63

1 Answers1

0

you can add this to your code

SET IDENTITY_INSERT Genre ON