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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display selected Columns in Query

Status
Not open for further replies.

Yerdon

Programmer
Jul 29, 2002
62
US
Hi Everyone,

This is a question that has come up for me over the years. I wonder if there is anybody out there who has come up with a way to do this?

Sometimes I don't know exactly what columns are in a table, and in order to find them I have to scroll through the whole table.

select * from mytable

It would be easier if I could do something like this:

select tmp% from mytable

This would return any columns that started with "tmp" in their name.

Any ideas?

Thank you!

Joseph

 
SELECT * FROM INFORMATION_SCHEMA.columns
WHERE LEFT(column_name,3) = 'tmp'
AND table_name = 'Mytable'

Read about the INFORMATION_SCHEMA views in BOL.

HTH,

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
I'll have the roast duck with the mango salsa.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top