Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Column Index in SQL Server 2008

Posted on 2011-03-19
4
Medium Priority
?
332 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:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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:Murray Brown
ID: 35174392
thanks very much
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

610 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