SQL columns

JCW2
JCW2 used Ask the Experts™
on
In SQL, how would I list columns from a table?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
SELECT *
FROM table
Top Expert 2010
Commented:
select name from syscolumns where id=object_id('tablename')

Commented:
* - all columns
type names of columns, separate with comma, if you what specific columns.

Example:

SELECT firstname, secondname, dob
FROM client
Expert of the Quarter 2010
Expert of the Year 2010
Commented:
You haven't specified what DBMS, but this should work on oracle/mysql/mssql/postgresql

select * from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME = 'somename'

Author

Commented:
Thank you for your help.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial