SELECT (case when a. colorder = 1 then d. name else null end) table name, A. colorder Field No., a. name field name, (Case when COLUMNPROPERTY (a. id, a. name, 'isidentity ') = 1 then' & radic; 'else' end) id, (Case when (SELECT count (*) FROM sysobjects WHERE (name in (SELECT name FROM sysindexes WHERE (id = a. id) AND (indid in (SELECT indid FROM sysindexkeys WHERE (id = a. id) AND (colid in (SELECT colid FROM syscolumns WHERE (id = a. id) AND (name = a. name ))))))) AND (xtype = 'PK')> 0 then' & radic; 'else' 'end) primary key, B. name type, a. length occupies the number of bytes, COLUMNPROPERTY (a. id, a. name, 'Precision ') as length, Isnull (COLUMNPROPERTY (. id,. name, 'scale'), 0) as decimal places, (case when. isnullable = 1 then' & radic; 'else' end) allow Null, Isnull (e. text, '') default value, isnull (g. [value],'') AS [description] FROM syscolumns Left join policypes B on a. xtype = B. xusertype Inner join sysobjects d on a. id = d. id and d. xtype = 'u' and d. name <> 'dtproperties' Left join syscomments e on a. cdefault = e. id Left join sys. extended_properties g on a. id = g. major_id AND a. colid = g. minor_id Left join sys. extended_properties f on d. id = f. class and f. minor_id = 0 Where B. name is not null -- WHERE d. name = 'Table to be query' -- this condition is added if only the specified table is queried. Order by a. id, a. colorder |