下面的sql语句可以查看表的信息。其中modify_date和create_date可以根据表的修改时间来查看。如果不需要删除后,就能看到所有表的字段信息
SELECT TOP (100) PERCENT d.name AS 表名, ISNULL(f.value, '') AS 表说明, a.name AS 字段名, 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 colid = a.colid))) THEN '是' ELSE '否' END AS 主键, b.name AS 类型, a.length AS 占用字节数,
COLUMNPROPERTY(a.id, a.name, 'PRECISION') AS 长度, ISNULL(COLUMNPROPERTY(a.id, a.name, 'Scale'), 0) AS 小数位数,
CASE WHEN a.isnullable = 1 THEN '是' ELSE '否' END AS 允许空, ISNULL(e.text, '') AS 默认值, ISNULL(g.value, '') AS 字段说明
FROM sys.syscolumns AS a LEFT OUTER JOIN
sys.systypes AS b ON a.xusertype = b.xusertype INNER JOIN
sys.sysobjects AS d ON a.id = d.id AND d.xtype = 'U' AND d.name <> 'dtproperties' LEFT OUTER JOIN
sys.syscomments AS e ON a.cdefault = e.id LEFT OUTER JOIN
sys.extended_properties AS g ON a.id = g.major_id AND a.colid = g.minor_id LEFT OUTER JOIN
sys.extended_properties AS f ON d.id = f.major_id AND f.minor_id = 0
WHERE (d.name IN
((SELECT name
FROM sys.tables
WHERE (modify_date >= '2016-12-01') AND (create_date >= '2016-12-01'))))
ORDER BY a.id, a.colorder