Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
srini99usa
Starting Member
4 Posts |
Posted - 2009-11-14 : 20:57:55
|
hi,i am importing data from access to sql,i am dumping all access values into staging sql table and from there into final sql table(using SP)i am getting "Violation of PRIMARY KEY constraint 'aaaaaCompany_PK'. Cannot insert duplicate key in object 'dbo.company'."my destination sql table is empty.the table scripts is: CREATE TABLE [dbo].[Company]( [CompanyNumber_PK] [int] NOT NULL, [CompanyName] [varchar](50) NULL, other 40 rows)CONSTRAINT [aaaaaCompany_PK] PRIMARY KEY NONCLUSTERED ( [CompanyNumber_PK] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]and some more other references--i think there is something do with : [aaaaaCompany_PK] PRIMARY KEY NONCLUSTERED and [CompanyNumber_PK] help me outThanks alot |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
srini99usa
Starting Member
4 Posts |
Posted - 2009-11-14 : 23:34:56
|
no, access db has no duplicates. Infact it has only 5 rows,with no duplicates |
 |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2009-11-15 : 01:24:15
|
Let's see the code for that SP. It's possible that there is a join that is producing the duplicate key value. Also, was your staging table empty before you imported from Access? It's either one of those 2 things, or at least one of the CompanyNumber_PK in Access is already in your target destination table.Primary Key is a Unique index, so the CompanyNumber_PK field must be unique. |
 |
|
|
|
|
|
|