Solved

Column Index in SQL Server 2008

Posted on 2011-03-19
4
321 Views
Last Modified: 2012-06-27
Hi

Where do you define the column index in a SQL server 2008 database? Is it just based on the position of the column eg 1st column = 0, 2nd column = 1 etc
I have to understand this for use in the folowing ASP.net code
oStartTime = CType(reader.GetTimeSpan(4), TimeSpan)
0
Comment
Question by:murbro
4 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 35171885
it depends on your SELECT query. It has nothing to do with the physical order in SQL (instead you do a SELECT *)
0
 
LVL 5

Expert Comment

by:ThakurVinay
ID: 35173943
to check which column is indexed...

you can use

sp_helpindex "tablename"

or

sp_help "tablename"

hth
vinay
0
 
LVL 28

Accepted Solution

by:
Ryan McCauley earned 500 total points
ID: 35174145
In your query, you're asking for the 5th column in your results, based on the order they appear in your SELECT statement. When you pull them back to .NET, the column numbers are zero-based, so column "4" like you're using above is the 5th column in the results.
0
 

Author Closing Comment

by:murbro
ID: 35174392
thanks very much
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

11 Experts available now in Live!

Get 1:1 Help Now