Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 70755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:46:51+00:00 2026-05-10T19:46:51+00:00

When creating an index over a column that is going to be UNIQUE (but

  • 0

When creating an index over a column that is going to be UNIQUE (but not the primary key of the table), SQL server let’s me choose a few options:

1) I can choose for it to be a Constraint or an Index.
I’m guessing this means that if I set it as constraint, it won’t use it when querying, only when writing. However, the only efficient way I can think of for SQL Server to enforce that constraint is by actually building an index. What is the use for this option?

2) Also, if I set it as ‘index’, it let’s me specify that it should ignore duplicate keys. This is the most puzzling for me…
I again guess it means the opposite of constraint. It probably means ‘use it when querying, but don’t even check when writing’.
But then why would I set it as UNIQUE?
I’m guessing there are some optimizations SQL Server can do, but i’d like to understand it better.

Does anyone know what exactly SQL Server does with these options?
What’s the use case for setting an index to be Unique, but ignore duplicate keys?

NOTE: This is for SQL Server 2000


EDIT: According to what you said, however… If I create a Constraint, will it be used to speed up queries that filter using the fields in the constraint?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:46:51+00:00Added an answer on May 10, 2026 at 7:46 pm

    A UNIQUE constraint is part of the ISO/ANSI SQL standard, whereas indexes are not because the Standard is implementation agnostic. SQL Server, in common with most SQL DBMSs, will use an index to implement a UNIQUE constraint.

    Arguably, using UNIQUE rather than index in a SQL script is slightly more portable but as always the proprietary syntax should not be ruled out if it provids opportunities for optimization etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 106k
  • Answers 106k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It not always work, but try to: Reorder tables in… May 11, 2026 at 8:54 pm
  • Editorial Team
    Editorial Team added an answer The solution that worked is: $postcode = trim(strip_tags($_REQUEST['postcode'])); $test =… May 11, 2026 at 8:54 pm
  • Editorial Team
    Editorial Team added an answer List items are normally block elements. Turn them into inline… May 11, 2026 at 8:54 pm

Related Questions

I have an app, which cycles through a huge number of records in a
So here are the details (I am using C# BTW): I receive a 32bpp
How do you specify the Fill Factor when creating an index in MySql?
I would like to know if there are general rules for creating an index

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.