"Jeff Magouirk" <ma*******@njc.org> wrote in message
news:10*************@corp.supernews.com...
I am new to using sqlserver and have been given the task to get the column
name, data type and the description from a given table and put this into
another table. Can this be done?
Thanks in advance.
Jeff Magouirk
You can get the column names and data types from INFORMATION_SCHEMA.COLUMNS:
select COLUMN_NAME, DATA_TYPE
from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME = 'MyTable'
I'm not sure what you mean by the "description" of a table. Assuming you
mean an extended property of some sort, you would need to look at
::fn_listextendedproperty(). But I'm not sure what the point is of storing
this information in your own table when it's already in the system tables
and automatically updated there for you - it might be easier to simply
retrieve it when you need it.
Simon