p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asp_databases thread: Re: select columns when part of column name is known


Message #1 by bopardikar@q... on Sat, 15 Jun 2002 00:22:07
Hi,

Thanx for you reply... I should have explained myself better
My table is dynamically generated by another program.
So the columns that r created have part of the column name
predefined and rest created dynamically... 

i got solution to my question... in case anybody is interested
I got the column names only by using followng statement

SELECT name FROM syscolumns 
 WHERE id IN (SELECT id FROM sysobjects 				 " 
WHERE name = 'myTable')

-Arundhati 


> AFAIK, you can't do that on a column basis. How would the database know 
w> hich column you are referring to? The only option you have is to use 

>     SELECT * FROM myTable.

> This will return all columns for the current table.

> Just out of curiosity... Why don't you know the column names??

> Imar

> 
>>  Hi all,
I>  want to select columns from a SQL table.
B> ut I just know part of the column name.
I> s there a way I can use wild cards in the Select
s> tatement so that I can give part of the name and
s> till be able to get the values?

> I would really appreciate any help.

> Regards,
A> rundhati
Message #2 by "Sandra" <salau@p...> on Fri, 14 Jun 2002 21:20:30
Hi Arundhati, 

One really quick way to find out column names (assuming that you have 
something like SQLPlus) is to do a describe on the table. 

describe myTable;

That'll tell you what fields and what types are in your table.

HTH,
Sandra ^_^

Message #3 by Arundhati Bopardikar <Bopardikar@Q...> on Thu, 13 Jun 2002 08:30:05 -0700
Hi all,
I want to select columns from a SQL table.
But I just know part of the column name.
Is there a way I can use wild cards in the Select
statement so that I can give part of the name and
still be able to get the values?

I would really appreciate any help.

Regards,
Arundhati
Message #4 by "Imar Spaanjaars" <Imar@S...> on Thu, 13 Jun 2002 19:43:34
AFAIK, you can't do that on a column basis. How would the database know 
which column you are referring to? The only option you have is to use 

    SELECT * FROM myTable.

This will return all columns for the current table.

Just out of curiosity... Why don't you know the column names??

Imar


> Hi all,
I want to select columns from a SQL table.
But I just know part of the column name.
Is there a way I can use wild cards in the Select
statement so that I can give part of the name and
still be able to get the values?

I would really appreciate any help.

Regards,
Arundhati

  Return to Index