尝试将值插入具有基于标识的主键列的表时,出现重复的主键错误。我不是要覆盖主键(列seq
),甚至在INSERT
语句中也没有。
我在另一个具有几乎相同的INSERT
语句的表上也遇到了错误。当前身份是960,该身份甚至不在表中。
错误:
违反PRIMARY KEY约束'PK_RunData_Times'。无法在对象'dbo.RunData_Times'中插入重复的键
插入声明:
INSERT INTO RunData_Times (RunID, PSAPtime, DispatchTime, EnrouteTime, AtSceneTime, TransportingTime, AtDestinationTime, AvailableTime, CanceledTime)
VALUES (@RID, @PT, @DT, @ET, @ST, @TT, @DET, @AT, @CT)
脚本作为表结构的创建表:
CREATE TABLE [dbo].[RunData_Times]
(
[seq] [bigint] IDENTITY(1,1) NOT NULL,
[RunID] [bigint] NOT NULL,
[PSAPtime] [nvarchar](32) NOT NULL,
[DispatchTime] [nvarchar](32) NULL,
[EnrouteTime] [nvarchar](32) NULL,
[AtSceneTime] [nvarchar](32) NULL,
[TransportingTime] [nvarchar](32) NULL,
[AtDestinationTime] [nvarchar](32) NULL,
[AvailableTime] [nvarchar](32) NULL,
[CanceledTime] [nvarchar](32) NULL,
CONSTRAINT [PK_RunData_Times]
PRIMARY KEY CLUSTERED ([seq] ASC)
) ON [PRIMARY]