There is already an Object named ‘PK_Users’ in the database Error..............

I’m trying to transfer a database to production using DTS, I get the following error.

----------------------------------------------------------------------------------------
There is already an Object named ‘PK_Users’ in the database
Could not create constraint. See previous error.
----------------------------------------------------------------------------------------

How would I get rid of this error or fix it so I can transfer the database to production server.

Any help would be appreciated
Thanks


adamullahAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mondayblueboyCommented:

adamullah,

Most probably that's because the DTS attempts to create a primary key constraint with a name that already exist in another table. You can either check the table creation script if there are more than two statements create primary constraint with a same name or check the database if there is a table has primary key with the same same.


Hope this helps
Cheers
NightmanCTOCommented:
You can't get rid of the error.

Effectively what is happening is you are attempting to create a Primary Key (PK) on the Users table.
Either this already exists in your production database (perhaps you have run this DTS package before, no?), or you DTS package is attempting to create it twice.

Option 1:
Remove all indexes, constraints (and possibly even tables) from production server prior to DTS package running. Obviously this will result in data loss, but the error will go away :)

Option 2:
Import data only. Don't import structure.

Option 3:
Create your database on the production server wikth T-SQL script, and step through it and debug. Then you can use 'if exists' to determine whether or not constraints need to be added.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.