Unanswered: How can I retrieve Description and other column information?
I want to know the query to retrieve Column information that we can see from table Design view of Enterprise manager, such as Column name, Pk or not, FK table, Data Type, Null or not, Description(Specially Descrition).
I too would like to get at the Description and I tried all of the above but Description doesn't seem to be there. I looked at all the INFORMATION_SCHEMA views and found nothing. I checked the system tables for the DB in question and found nothing. Could the Description be something internal to EM that isn't available to clients?
It works!!! Assuming a Table name of 'KB' and a column named 'Title' this gets the description.
declare @tbid integer
declare @colid integer
Select @tbid=id from sysobjects where xtype='u' and name='KB'
Select @colid = colid from syscolumns Where id=@tbid And name='Title'
select value from sysproperties where id=@tbid and smallid=@colid and name='MS_Description'
Now I am finishing ...
This works! the following three tables joined gives what I asked.
I hope this helps all...
Thank you all for considering
SELECT sysobjects.name AS [Table], syscolumns.name AS [Column], sysproperties.[value] AS Description
FROM (sysobjects INNER JOIN syscolumns
ON syscolumns.id = sysobjects.id) LEFT JOIN sysproperties
ON sysproperties.smallid = syscolumns.colid AND
sysproperties.id = syscolumns.id
where sysobjects.name = 'Orders'
sysobjects.name : table Name (WHERE sysobjects.xtype = 'U')
sysobjects.id : table ID
sysproperties.smallid : Column id
sysproperties.[value] : Description
You can add following
WHERE sysobjects.xtype = 'U' xtype='U' means only select Table object