Simple troubleshooting here:
Disable or drop primary key constrain and load data.
Run a query to find duplicate entries in proposed key column.
If there no duplicates, then add constrain to copy to a new table with such constrain.
質問
I have a following problem. I have a .tsv
file (for movies, years and genres). I want to upload it to SQL Server 2012.
I created a table
CREATE TABLE Genres2
(
MovieName varchar(255) NOT NULL,
Year int NOT NULL,
Genre varchar(255) NOT NULL
PRIMARY KEY (MovieName, Year)
);
While uploading it
BULK INSERT Genres3
FROM 'c:\Users\genres6.tsv'
WITH
(
FIELDTERMINATOR='\t',
ROWTERMINATOR='\n'
);
I get an error
The duplicate key value is
But notepad++ says, that there is only one such value in the file.
Any ideas how to solve it? Thank you in advance.
解決
Simple troubleshooting here:
Disable or drop primary key constrain and load data.
Run a query to find duplicate entries in proposed key column.
If there no duplicates, then add constrain to copy to a new table with such constrain.