February 22, 2008 at 7:54 am
Pretty basic question ... I've been researching for hours. All the examples I have found seem to be exclusively for system tables whose columns are in syscolumns.
How can i get the column names from say table "Employees"...?
February 22, 2008 at 7:59 am
If you only need to know the column names then why don't you use select * from Employees
February 22, 2008 at 8:25 am
wpp9786 (2/22/2008)
Pretty basic question ... I've been researching for hours. All the examples I have found seem to be exclusively for system tables whose columns are in syscolumns.How can i get the column names from say table "Employees"...?
What's wrong with using the sytems tables (or schema views)?
You could do as Chris suggested. Or you could run sp_help 'Employees', which gives you more than just the column names.
Or you could do:
select * from information_schema.columns where table_name = 'Employees'
February 22, 2008 at 8:58 am
wpp9786 (2/22/2008)
Pretty basic question ... I've been researching for hours. All the examples I have found seem to be exclusively for system tables whose columns are in syscolumns.How can i get the column names from say table "Employees"...?
Every table's column definitions is tracked in syscolumns (not just system tables). that's its mission in life.
In 2005, syscolumns is actually a system view (and technically - it's a synonym to the sys.all_columns view). It's not a table.
Like has been pointed out previously - if you don't like using system views, use the "INFORMATION_SCHEMA" views - that's what they're designed for.
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply