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
 SQL Server Development (2000)
 Retrive rows using field number

Author  Topic 

vinoth_vasanth
Starting Member

3 Posts

Posted - 2006-02-07 : 04:35:57
Hi all,

Could anyone please let me know how can I retrive rows in select statement in which the where clause will have the field number rather than field name?

If you have any queried let me know.

Thanks in advance,
Vinoth

Kristen
Test

22859 Posts

Posted - 2006-02-07 : 04:48:02
Hi vinoth_vasanth, Welcome to SQL Team!

Might help if you explained why you need to do this because its generally a bad approach - what happens if the sequence of the columns changes in the future - e.g. a new one is inserted, or an old one dropped.

Kristen
Go to Top of Page

vinoth_vasanth
Starting Member

3 Posts

Posted - 2006-02-07 : 04:52:26
Hi Kristen,

Thanks for ur reply. I have a csv file without header field which will be generated from an application. Its immpossible to get the header field info. So i have to use field number instead of the field name. Hope u get it now.

Vinoth

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-02-07 : 08:33:44
So the CSV is inserted into a new table with enough columns to match the CSV file?

If so can't you just call those columns "COLUMN_1", "COLUMN_2" ... and then reference them like normal columns?

Or are you needing to process the CSV file via a Temporary Table of some sort and reference the columns dynamically?

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-07 : 09:06:40
Also have a look at this
http://sqlteam.com/forums/topic.asp?TOPIC_ID=53384

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

vinoth_vasanth
Starting Member

3 Posts

Posted - 2006-02-08 : 01:17:59
Hey Kristen, you are right, I wouldnt like to go with a table, is there any other way to extract the values from the CSV files? I know its stupid but wanna try!!!
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-02-08 : 03:09:46
I don't see why you shouldn't get the file into a Temporary Table, if that's what you need to do, and then manipulate/Select the data from there.

But I think it would be a bit daft to use SQL to reference the file direct as-if-it-was-a-database-table!

Kristen
Go to Top of Page
   

- Advertisement -