Solved

Primary Key Not Showing up in SQL Server Management Studio

Posted on 2013-01-30
6
718 Views
Last Modified: 2013-01-30
I am trying to set up replication.  When setting up the publisher there are several hundred tables that I cannot select because it states there are no primary keys.  However when I go into SQL Management Studio and try to create a primary key on one of those tables it will not create it because the primary key already exists.  When I view the keys for any of these tables or in design view there is no primary key shown yet it exists.  We have  a copy of this database in another environment and when I view the same table the primary keys are visible.  I thought it might be my SQL Management Studio so I tried it from several other workstations and still the same result.  I guess since it does not appear in SSMS the replication wizard thinks it does not exist as well.  Any idea what the issue might be?  Please advise.
0
Comment
Question by:Gary Harper
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 43

Expert Comment

by:Eugene Z
ID: 38837831
if you had PK - Replication would take this table
you may pointed to wrong db;

check PK from SSMS or code

run sp_help yourtable
and sp_helpindex yourtablename

--can you post the pk creation error?
0
 
LVL 24

Expert Comment

by:DBAduck - Ben Miller
ID: 38837866
I would also check your permissions on those tables to ensure that you can View the meta data.  Typically that would be a granular permission, but it is possible that you cannot view the meta data for those tables.
0
 

Author Comment

by:Gary Harper
ID: 38838030
Here is the PK creation error.

/*
   Wednesday, January 30, 20138:33:01 PM
   User: food
   Server: LIMSDB1\LIMS34
   Database: food
   Application:
*/

'EFiles' table
- Unable to create index 'PK_EFiles'.  
The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'food.EFiles' and the index name 'PK_EFiles'. The duplicate key value is (Harran).
Could not create constraint. See previous errors.
The statement has been terminated.
0
Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

 
LVL 24

Accepted Solution

by:
DBAduck - Ben Miller earned 500 total points
ID: 38838038
OK, that is different.  This means that there is a key in the column being used for the Primary Key that is duplicated.  By definition, the Primary Key is UNIQUE and if there is a dup key, this is not Unique, so it will not create it.

Resolve the duplicate key and you will be able to create a Primary Key.
0
 

Author Comment

by:Gary Harper
ID: 38838085
Ok.  That is exactly the case.  Thank you.
0
 
LVL 43

Expert Comment

by:Eugene Z
ID: 38838097
it is cool that you liked my post: "can you post the pk creation error? " :)
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question