首页 > 代码库 > Sql获取数据表字段说明

Sql获取数据表字段说明

SELECT  Sysobjects.name AS TABLE_NAME ,        syscolumns.Id ,        syscolumns.name AS COLUMN_NAME ,        systypes.name AS DATA_TYPE ,        syscolumns.length AS CHARACTER_MAXIMUM_LENGTH ,        sys.extended_properties.[value] AS COLUMN_DESCRIPTION ,        syscomments.text AS COLUMN_DEFAULT ,        syscolumns.isnullable AS IS_NULLABLEFROM    syscolumns        INNER JOIN systypes ON syscolumns.xtype = systypes.xtype        LEFT JOIN sysobjects ON syscolumns.id = sysobjects.id        LEFT OUTER JOIN sys.extended_properties ON ( sys.extended_properties.minor_id = syscolumns.colid                                                     AND sys.extended_properties.major_id = syscolumns.id                                                   )        LEFT OUTER JOIN syscomments ON syscolumns.cdefault = syscomments.idWHERE   syscolumns.id IN ( SELECT   id                           FROM     SYSOBJECTS                           WHERE    xtype = ‘U‘ )        AND ( systypes.name <> ‘sysname‘ ) AND Sysobjects.name=‘OriginalData‘	-- 表名称ORDER BY syscolumns.colid

  见图:

技术分享

Sql获取数据表字段说明