赢友网络

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_NULLABLE
FROM    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.id
WHERE   syscolumns.id IN ( SELECT   id
                           FROM     SYSOBJECTS
                           WHERE    xtype = 'U' )
        AND ( systypes.name <> 'sysname' ) AND Sysobjects.name='OriginalData'	-- 表名称
ORDER BY syscolumns.colid

  见图:

posted @ 2015-01-24 11:48  新生帝  阅读(537)  评论(0编辑  收藏  举报
赢友网络