0
使用SQL Server 2008無法插入一排表
customerinfo腳本
CREATE TABLE [dbo].[customerinfo](
[customer#] [int] IDENTITY(1,1) NOT NULL,
[acc#] [varchar](10) NOT NULL,
CONSTRAINT [PK_unc_customerinfo] PRIMARY KEY NONCLUSTERED
(
[customer#] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
CONSTRAINT [idx_u_customerinfo] UNIQUE NONCLUSTERED
(
[acct#] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
創建表重置身份場補種0,然後我嘗試在表中插入行。獲取錯誤爲
Violation of UNIQUE KEY constraint 'idx_u_customerinfo'. Cannot insert duplicate key in object 'dbo.customerinfo'. The duplicate key value is (50950/01950).
如何糾正此問題。
你想喲能夠在列'ACC#添加重複值'? –
另外,您要添加的值看起來像11個字符,而列僅爲10個字符。也許你正在獲取重複的值,因爲最後一個字符被切斷。 –
[customer#]是主鍵...它不允許重複值 – Jesuraja