Solved

Primary Key Not Showing up in SQL Server Management Studio

Posted on 2013-01-30
6
630 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SLQ View not updating 10 47
Backup Job question 4 19
SQL Server 2012 Row Selection 2 30
select over clause 1 0
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

757 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

18 Experts available now in Live!

Get 1:1 Help Now