Create a view first
Create View FieldDesc asselect o.name as table_name, c.name as field_name, t.name as type, c.length AS
Length, C.isnullable Asnullable, Convert (VARCHAR (30), P.Value) AS DESP from Syscolumns C Join Systems T on C.XTYPE = T.XUSERTYPEJOIN SYSOBJECTS O On O.ID = C.ID Left Join Sysproperties P on P.SMallid = C.Colid and p.id = o.id where o.XTYPE = 'u'
When queries: select * from FieldDesc Where Table_name = 'Your Table name
There is also a stronger statement, it is Zou Jian, and also wrote it.
SELECT (CASE WHEN A.COLORDER = 1 THEN D.NAME ELSE '' END) N 'Name', A.COLORDER N 'Field Series', A.Name N' Field Name, (Case When ColumnProperty (A.ID , a.name, 'isidentity') = 1 Ten '√'lse' 'end) N' Identification '(Case When (Select Count (*) from sysobjects where (select name from sysindexes where (id = A) .id) and (SELECT Indid from sysindexkeys where (id = a.id) AND (Colid in (select colid from syscolumns where (id = a.id) and (name = a.name)))))))))))) )> 0 THEN '√' else '' end) n 'primary key', B.Name n 'type', A.Length N 'occupies bytes', ColumnProperty (A.ID) , A.Name, 'Precision') AS N 'Length', ISNULL (ColumnProperty (A.ID, A.NAME, 'Scale'), 0) AS N 'Digital Number (Case When A.isnullable = 1 THEN '√'ELSE' 'end) N' Allows empty ', isnull (e.text,' ') n' default ', isnull (g. [value],' ') AS n' field description '--into ## tx