Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Specifying a column by index in queries

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-12-11 : 09:45:08
Pete writes "HI,

I have some csv text file that I open with the Micosoft Text Driver, but they are not headed with column names. I do however know the positions or indexes of the columns I am interested in.

How can I write a select query with a where clause on a specific column from the file? or how do you identify columns in a query by index no?

Many Thanks.
Pete."

robvolk
Most Valuable Yak

15732 Posts

Posted - 2001-12-11 : 12:22:23
You have to add column names somehow, either in the text file itself, or imported into a SQL Server table, and SELECT from there. I know you can order by a column position, but the SELECT and WHERE clauses definitely need column names.

I haven't played with this driver and text files in SQL Server, but I believe it may generate column names that you can use (col1, field1, etc.) Try performing a SELECT * FROM... with no WHERE clause and see what comes up in query analyzer.

Go to Top of Page
   

- Advertisement -