1 USE database1
2 SELECT
3 表名 = CASE a.colorder WHEN 1 THEN c.name ELSE '' END,
4 序 = a.colorder,
5 字段名 = a.name,
6 标识 = CASE COLUMNPROPERTY(a.id,a.name,'IsIdentity') WHEN 1 THEN '√' ELSE '' END,
7 主键 = CASE
8 WHEN EXISTS (
9 SELECT *
10 FROM sysobjects
11 WHERE xtype='PK' AND name IN (
12 SELECT name
13 FROM sysindexes
14 WHERE id=a.id AND indid IN (
15 SELECT indid
16 FROM sysindexkeys
17 WHERE id=a.id AND colid IN (
18 SELECT colid
19 FROM syscolumns
20 WHERE id=a.id AND name=a.name
21 )
22 )
23 )
24 )
25 THEN '√'
26 ELSE ''
27 END,
28 类型 = b.name,
29 字节数 = a.length,
30 长度 = COLUMNPROPERTY(a.id,a.name,'Precision'),
31 小数 = CASE ISNULL(COLUMNPROPERTY(a.id,a.name,'Scale'),0)
32 WHEN 0 THEN ''
33 ELSE CAST(COLUMNPROPERTY(a.id,a.name,'Scale') AS VARCHAR)
34 END,
35 允许空 = CASE a.isnullable WHEN 1 THEN '√' ELSE '' END,
36 默认值 = ISNULL(d.[text],''),
37 说明 = ISNULL(e.[value],'')
38 FROM syscolumns a
39 LEFT JOIN systypes b ON a.xtype=b.xusertype
40 INNER JOIN sysobjects c ON a.id=c.id AND c.xtype='U' AND c.name<>'dtproperties'
41 LEFT JOIN syscomments d ON a.cdefault=d.id
42 LEFT JOIN sysproperties e ON a.id=e.id AND a.colid=e.smallid
2 SELECT
3 表名 = CASE a.colorder WHEN 1 THEN c.name ELSE '' END,
4 序 = a.colorder,
5 字段名 = a.name,
6 标识 = CASE COLUMNPROPERTY(a.id,a.name,'IsIdentity') WHEN 1 THEN '√' ELSE '' END,
7 主键 = CASE
8 WHEN EXISTS (
9 SELECT *
10 FROM sysobjects
11 WHERE xtype='PK' AND name IN (
12 SELECT name
13 FROM sysindexes
14 WHERE id=a.id AND indid IN (
15 SELECT indid
16 FROM sysindexkeys
17 WHERE id=a.id AND colid IN (
18 SELECT colid
19 FROM syscolumns
20 WHERE id=a.id AND name=a.name
21 )
22 )
23 )
24 )
25 THEN '√'
26 ELSE ''
27 END,
28 类型 = b.name,
29 字节数 = a.length,
30 长度 = COLUMNPROPERTY(a.id,a.name,'Precision'),
31 小数 = CASE ISNULL(COLUMNPROPERTY(a.id,a.name,'Scale'),0)
32 WHEN 0 THEN ''
33 ELSE CAST(COLUMNPROPERTY(a.id,a.name,'Scale') AS VARCHAR)
34 END,
35 允许空 = CASE a.isnullable WHEN 1 THEN '√' ELSE '' END,
36 默认值 = ISNULL(d.[text],''),
37 说明 = ISNULL(e.[value],'')
38 FROM syscolumns a
39 LEFT JOIN systypes b ON a.xtype=b.xusertype
40 INNER JOIN sysobjects c ON a.id=c.id AND c.xtype='U' AND c.name<>'dtproperties'
41 LEFT JOIN syscomments d ON a.cdefault=d.id
42 LEFT JOIN sysproperties e ON a.id=e.id AND a.colid=e.smallid