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 63191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:35:38+00:00 2026-05-10T18:35:38+00:00

I need to index a varchar field on my table in MS SQL Server

  • 0

I need to index a varchar field on my table in MS SQL Server 2005, but it’s not clear to me how to do so. If I try to add a non-clustered index on the field, it says ‘Column ‘xxxx’ in table ‘mytable’ is of a type that is invalid for use as a key column in an index’

My table has an auto-increment int ID that is set as the primary key on the table. If I set this property as the index, and then add my varchar column as an ‘included column’, the index goes through. But I’m not sure that’s what I want – I want to be able to search the table based on the varchar field alone, and my understanding of indexes was that all indexed elements had to be provided to actually see a speedup in the query, but I don’t want to have to included the int ID (because I don’t know what it is, at the time of this given query).

Am I trying to do this incorrectly? Would the ID + my varchar as an included column accomplish what I am looking for?

  • 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-10T18:35:38+00:00Added an answer on May 10, 2026 at 6:35 pm

    Is your varchar(max)? I think those aren’t allowed to be used in an index.

    Otherwise, post your CREATE TABLE statement, normally there is no problem adding a varchar to an index.

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

Sidebar

Ask A Question

Stats

  • Questions 78k
  • Answers 78k
  • 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
  • added an answer The .net documentation itself referes to this as: 'the default… May 11, 2026 at 3:53 pm
  • added an answer I suspect that the Property Grid does not support your… May 11, 2026 at 3:53 pm
  • added an answer Not so familiar with iis7 but I can help you… May 11, 2026 at 3:53 pm

Related Questions

Just a quick database design question: Do you ALWAYS use an ID field in
Consider the following SQL Server 2005/2008 query: Select [UID], [DESC] From SomeTable Order By
I'm trying to design a database for a sports meeting. I think I've got
I'm using cakePHP and I want to add a First and Last name column

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.