Solved

Column Index in SQL Server 2008

Posted on 2011-03-19
4
322 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 70

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

776 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