Solved

Column Index in SQL Server 2008

Posted on 2011-03-19
4
320 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
thanks very much
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

     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 …
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

771 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