Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I select a column without using its name?

Status
Not open for further replies.

Snakeroot

Technical User
Oct 4, 2006
112
0
0
US
I searched previous posts and the FAQ, but didn't see anything about this.

I have a table that is generated by a 3rd party software. The name of the second column is not static. It contains a date reference. For instance one time the column name may be FFEB07 and another time it may be FJAN1208.

I'd like to create a view so that I can report off of this table, but have a static name for the second column no matter what the 3rd party software decides to call it today.

I was wondering if there is a way to reference columns by an index number of some sort, so I could just call "Column(2)" each time without having to know it's name?

I'm using SQL Server 2008 R2.

Thanks for any help or point in the right direction.
 
Not that I know of. Assuming that you want the view so you don't have to refence a new table and fields each time?

A good solution might be to insert the records into a table that you do know the names of.

insert into mytable
Select *
from oddtable

Simi
 
Ahh, that makes sense. I got stuck looking at the problem from one angle. Thanks for the suggestion!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top