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

Related Questions

For example, I always generate an auto-increment field for the users table, but I
I need to index a whole lot of webpages, what good webcrawler utilities are
Am building a Book search API using Lucene. I need to index Book Name,Author,
I need an associative container that makes me index a certain object through a
I need an idea for an efficient index/search algorithm, and/or data structure, for determining
I need something in between a full text search and an index search: I
I need to perform a HTTP GET from PHP. More specifically, from within /index.php
I need to match up two almost-the-same long freetext strings; i.e., to find index-to-index
I have a directory with PDF files that I need to create an index
I'm writing an automation script with autoit: http://www.autoitscript.com/autoit3/index.shtml . In the process I need

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.