質問

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:

  1. Disable or drop primary key constrain and load data.

  2. Run a query to find duplicate entries in proposed key column.

  3. If there no duplicates, then add constrain to copy to a new table with such constrain.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top