• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 790
  • Last Modified:

Primary Key Not Showing up in SQL Server Management Studio

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
Gary Harper
Asked:
Gary Harper
  • 2
  • 2
  • 2
1 Solution
 
Eugene ZCommented:
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
 
DBAduck - Ben MillerPrincipal ConsultantCommented:
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
 
Gary HarperAuthor Commented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
DBAduck - Ben MillerPrincipal ConsultantCommented:
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
 
Gary HarperAuthor Commented:
Ok.  That is exactly the case.  Thank you.
0
 
Eugene ZCommented:
it is cool that you liked my post: "can you post the pk creation error? " :)
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now