Solved

Primary Key Not Showing up in SQL Server Management Studio

Posted on 2013-01-30
6
638 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
  • 2
  • 2
  • 2
6 Comments
 
LVL 42

Expert Comment

by:EugeneZ
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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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 42

Expert Comment

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

932 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now