troubleshooting Question

How to add primary keys to database tables with identical column names

Avatar of fieldb1
fieldb1Flag for United States of America asked on
Microsoft DevelopmentMicrosoft SQL Server 2008
4 Comments1 Solution238 ViewsLast Modified:
I have imported a bunch of excel spreadsheets into a SQL Server Database. Each table is named for a spreadsheet which represents one month. Now, the fields of each table are identical, being as the various tables represent different monthly data. What is the best way to add primary keys to these tables? I would like to use the Truck# field, but after adding that key to one table I get an error when altering other tables. The error is below.

Msg 2714, Level 16, State 4, Line 1
There is already an object named 'PK_Truck#' in the database.
Msg 1750, Level 16, State 0, Line 1
Could not create constraint. See previous errors.

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros