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

  • SEARCH
  • Home
  • 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 7819885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:06:04+00:00 2026-06-02T07:06:04+00:00

I have a table called countries and I define the country_name column to be

  • 0

I have a table called countries and I define the country_name column to be unique by creating a “Index/Key” of type “Unique Key” on SQL Server 2008 R2.

But I have the following questions:

  1. will creating “Index/Key” of type “Unique Key” automatically create a non-clustered index on this column?
  2. if I change the type from being “Unique Key” to “Index” and I keep the IsUnique value to be “Yes”,, then will there be any differences ?
  3. so why there are two options “Unique Key” and “Index” I think the two are the same ?
  • 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. Editorial Team
    Editorial Team
    2026-06-02T07:06:10+00:00Added an answer on June 2, 2026 at 7:06 am

    A unique constraint is implemented behind the scenes as a unique index, so it doesn’t really matter how you specify it. I tend to implement it simply as:

    ALTER TABLE dbo.foo ADD CONSTRAINT UQ_bar UNIQUE(bar);
    

    Some people create a unique index instead, e.g.

    CREATE UNIQUE INDEX IX_UQ_Bar ON dbo.foo(bar);
    

    The difference is in the intent – if you are creating the constraint to enforce uniqueness/business rules, you create a constraint, if you are doing so to assist query performance, it might be more logical to create a unique index. Again, under the covers it’s the same implementation, but the road you take to get there may help document your intent.

    I think there are multiple options to adhere to both previous Sybase functionality as well as to adhere to the ANSI standard (even though unique constraints don’t adhere to the standard 100%, since they only allow one NULL value – a unique index, on the other hand, can work around this by adding a WHERE clause (WHERE col IS NOT NULL) on SQL Server 2008 and greater).

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

Sidebar

Related Questions

I have a sql server 2005 table called ZipCode, which has all the US
I have table in my SQL Server database called OrderDetail which stores the order
I have table called Buttons. Buttons table i have column button_number . Table contain
I have a table called scheduler_sched which has several columns, including a column called
i have table called type which contains data family,individual i want in some pages
I have table name called Person with following column names P_Id(int), LastName(varchar), FirstName (varchar).
I have a table called Shoppings in my SQL db. This one has a
I am creating a SQLite database for my iPhone projects. I have table called
i have table called table1 and it looks like the below record type tran_ref_number
I have a table called products with primary key Id . I want to

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.