SQL gets table properties

zhaozj2021-02-16  88

SELECT? Table name = Case When a.colorder = 1 Then D.Name Else '' end ,? Table Description = Case When a.colorder = 1 Then ISNULL (F.Value, '') Else 'End, "Field Sequence Number = a.colorder,? Field name = a.Name,? Identifier = case when columnproperty (A.ID, a.Name, 'isidentity') = 1 Ten '√'ELSE' 'end ,? Primary key = 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 ??)) THEN ' √ 'else' 'end ,? Type = B.Name, Total bytes = a.length, length = ColumnProperty (A.ID, A.NAME,' Precision '), Digital number = ISNULL (ColumnProperty (A.ID, A.Name, 'Scale'), 0) ,? Field Description = ISNULL (g. [Value], '') from syscolumns a? Left join systempes 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 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 the table' ??? Just query the specified table, plus this condition Order by A.ID, A.COLORDER

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

New Post(0)