Column Index in SQL Server 2008


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 code
oStartTime = CType(reader.GetTimeSpan(4), TimeSpan)
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
Ryan McCauleyConnect With a Mentor Data and Analytics ManagerCommented:
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.
Éric MoreauSenior .Net ConsultantCommented:
it depends on your SELECT query. It has nothing to do with the physical order in SQL (instead you do a SELECT *)
to check which column is indexed...

you can use

sp_helpindex "tablename"


sp_help "tablename"

Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
thanks very much
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.