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.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 access to sql server

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 out

Thanks alot

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-11-14 : 23:12:34
Your Access data has duplicates for CompanyNumber_PK. You'll need to correct that or change your PK to something that is unique.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

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
Go to Top of Page

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.
Go to Top of Page
   

- Advertisement -