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
 Other Forums
 Other Topics
 Querying Excel With Range

Author  Topic 

karuna
Aged Yak Warrior

582 Posts

Posted - 2008-05-20 : 12:25:23
I have a classic ASP application, which needs to query an excel file. My current query looks like this and it works fine.


SELECT colhdr1,colhdr2,colhdr3 FROM [Sheet1$].


Now the problem is, for some reason if the colhdrX spelled wrong, this query will fail. So without using a colhdrX, how can I rewrite this using a range. Say colhdr1 will always be A, colhdr2 will always be E and so on...

I tried to rewrite this as below and it is not working. Any ideas how can I achieve this?

SELECT [A:A] AS colhdr1,[E:E] AS colhdr2,[D:D] AS colhdr3 FROM [Sheet1$].


Thanks
Karunakaran
   

- Advertisement -