Primary Key and Index Key in SQL 2005

Posted on 2007-07-20
Last Modified: 2010-03-19
When I make a field a primary key does it automatically make it an index also?
If I do a lot of searching on UserId and I make it a primary key should I also make it an Index Column?
Question by:mattphung
    LVL 15

    Expert Comment

    yes, if there is no clustered index on the table when you assign the PK, it auto-assigned the PK as a clustered index

    Author Comment

    thanks derek-
    --->If I do a lot of searching on UserId and I make it a primary key should I also make it an Index Column?
    but do I still need to make it an Index Column?

    Also, what's a clustered index? What types of indexes are there?
    LVL 15

    Accepted Solution

    There are clustered and non-clustered indexes. There can only be 1 clustered index on a table. That determines the order in which the records are physically stored in the table.

    In your case, since userid is your PK, you don't need to create any additional indexes on it.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
    Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
    Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

    729 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

    19 Experts available now in Live!

    Get 1:1 Help Now