Solved

Ignore Duplicate Keys Disabled

Posted on 2012-03-27
8
1,468 Views
Last Modified: 2014-04-22
I have a situation where it makes sense to have Ignore Duplicate Keys On. The problem is that the option is disabled for the index and I can't figure out why. The index is a Primary Key Unique Clustered index.

What am I missing? By the way, I am able to create the index with a script and IGNORE_DUP_KEY = ON, but don't understand why I can't accomplish the same thing with the user interface.

Indexes/Keys Dialog
0
Comment
Question by:TechMommy
[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
  • 5
  • 2
8 Comments
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37775564
remove primary key from table, a primary key means it will not allow duplicate keys in that column. how can you have a primary key and thus unique clustered index and allow duplicate keys as well....
0
 
LVL 11

Author Comment

by:TechMommy
ID: 37778155
Ignore Duplicate Keys does NOT allow duplicate rows to be inserted. It simply suppresses the error message associated with the procedure causing the error and instead produces a warning message (see BOL). I am using it because I want to reject the duplicates without rolling back the entire Insert statement. It works perfectly for other tables, but is for some reason disabled for this table. Once I set it in script it works beautifully. The primary key is respected by the error is suppressed.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 37778168
The index is a Primary Key Unique Clustered index.
A primary key is a CONSTRAINT and not an INDEX.  (SQL Server enforces a Primary Key CONSTRAINT with a clustered or non-clustered unique index)
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 11

Author Comment

by:TechMommy
ID: 37778192
So why is the option disabled via the user interface, but scripts just fine, and why once I script it does it show up in the UI as Yes, but is still disabled?
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 37779894
There are many attributes in the UI that are not enabled.  But feel free to post your SQL script.
0
 
LVL 11

Author Comment

by:TechMommy
ID: 37780288
The curious thing is that the Ignore Duplicate Keys feature is SOMETIMES available via the user interface (for certain indexes), and not for others. I don't see a difference between the indexes that it is available for and those that it isn't. I can certainly use my script (which appears below), but I was hoping to get some incite as to why it is available sometimes and not others.

ALTER TABLE [dbo].[tblWorkers] ADD  CONSTRAINT [PK_tblWorkers] PRIMARY KEY CLUSTERED 
(
	[WorkerID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = ON, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

Open in new window

0
 
LVL 11

Accepted Solution

by:
TechMommy earned 0 total points
ID: 37780292
Just as an added comment, I just noticed that it does appear to be consistently available in the Index Properties dialog. So, I seem to be able to always set it there graphically.

Alternative for Setting Ignore Duplicate Keys
That basically solves my problem, but if anyone knows why it isn't consistently available in the Indexes/Keys dialog, I'd be really curious to know the answer.
0
 
LVL 11

Author Closing Comment

by:TechMommy
ID: 40014329
This question was never answered. As mentioned in my previous comment, I was able to solve my own problem, but never figured out the source of the inconsistent behavior.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
migrate a SQL 2008 to 2016, 2 45
Help Required 3 117
sql how to count case when 4 29
Problem when I run a simple storeproc - help 4 30
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

756 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