How to get all table fields and fields in the database

xiaoxiao2021-03-06  110

How to get all the table fields and fields in the database to describe the following information, from a brother of 9CBS from the SQL moderator: SQL SELECT (CASE WHEN A.COLORDER = 1 THEN D.NAME ELSE '' END) N 'Table Name, a.colorder n 'field number', a.name n 'field name', (Case When ColumnProperty (A.ID, A.NAME, 'ISIDENTITY') = 1 Ten '√'ELSE' 'end) N 'Logo' (Case When (Select Count (*) from Sysobjects Where (Select Name from Sysindexes Where (ID = A.ID) And (Indid In (SELECT Indid from sysindexkeys where (id = a.id) (Colid in (select colid from syscolumns where (id = a.id))))))))))))))))))))))))> 0 THEN '√' else 'end) N 'primary key', B.Name n 'type', A.Length N 'occupying 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 '√'lse' 'end) N' Allow empty ', isnull (E.Text, '') N 'Default', ISNULL (G. [Value], '') AS N 'Field Description' - Into ## TX

From syscolumns a left a.xtype = B.XUSERTYPEINNER JOIN SYSOBJECTS D on A.ID = D.ID and D.XTYPE = 'u' and d.name <> DTPROPERTIES'LEFT JOIN SYSCOMFAMFAMFAMENTS EON A. CDEFAULT = E.IDLEFT JOIN SYSPROPERTIES GON A. ID = g.id and a.colid = g.smallid Order by Object_name (A.ID), A.COLORDER

A word, cool, can also save a lot of trouble when DD. If not very clear, you can put the above code on the SQL query analyzer to run, you know (of course, you have to open a database)

转载请注明原文地址:https://www.9cbs.com/read-100691.html

New Post(0)