If you want to get a vertical table structure, you can query system tables.

xiaoxiao2021-03-06  39

- If it is to get a vertical table structure, you can query system tables.

Select Name = Case When a.colorder = 1 Then D.Name Else '' end, table Description = Case When a.colorder = 1 THEN INULL (F.Value, '') Else '' end, field number = a. Colorder, Field Name = A.Name, Identifies = Case When ColumnProperty (A.ID, A.Name, 'Isidentity') = 1 Then '√'ELSE' 'End, Programs = Case WHEN EXISTS (SELECT 1 from sysobjects where xtype = 'Pk' and name in (select Name from sysindexes where indid in (select indid from sysindexkeys where id = a.id and color = a.colid))) "√ 'else' end, type = B.Name, Total bytes = a.length, length = columnproperty (A.ID, A.NAME, 'Precision'), count number = ISNULL (ColumnProperty (A.ID, A.NAME, 'Scale'), 0), Allow empty = case when a.isnullable = 1 Then '√'lse' 'end, default = isnull (E.TEXT,' '), field description = ISNULL (g. [Value],' ') from syscolumns a left Join systemypes b.xUsertype = 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 sysproperties g on a.id = g.id and a.colid = g.smallid left join sysproperties f on d.id = f.id and f.smallid = 0 - where d.name = 'To query Table ' - If you only query the specified table, add this condition Order by a.id, a.colorder - or use the system stored procedure

- Display the table structure information of the specified table, sysObjects is the table name exec sp_columns 'sysobjects'

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

New Post(0)