1
--SELECT NAME FROM SYSOBJECTS WHERE TYPE = 'U'
2
----显示数据库的所有表的属性值
3
use bajsyy
4
GO
5
6
select
7
( case when a.colorder = 1 then d.name else '' end ) 表名,
8
a.colorder 字段序号,
9
a.name 字段名,
10
( case when COLUMNPROPERTY (a.id,a.name,'isidentity') = 1 then '√' else '' end ) 标识,
11
( case when (
12
select count(*) from sysobjects
13
where name in (
14
select name from sysindexes
15
where (id = a.id ) and ( indid in
16
(select indid from sysindexkeys where
17
( id = a.id ) and ( colid in (
18
select colid from syscolumns
19
where ( id = a.id ) and ( name = a.name ))))))
20
and ( xtype ='PK')) > 0 then '√' else '' end ) 主键,
21
b.name 类型,
22
a.length 字节数,
23
COLUMNPROPERTY ( a.id,a.name ,'PRECISION' ) as 长度,
24
isnull ( COLUMNPROPERTY ( a.id,a.name ,'Scale'),0) as 小数位数,
25
(case when a.isnullable = 1 then '√' else '' end ) 允许空,
26
isnull ( e.text,'') 默认值,
27
isnull (g.[value],'' ) as 字段说明
28
from syscolumns a left join systypes b
29
on a.xtype = b.xusertype
30
inner join sysobjects d
31
on a.id = d.id and d.xtype='U' and d.name <> 'dtproperties'
32
left join syscomments e
33
on a.cdefault = e.id
34
left join sysproperties g
35
on a.id = g.id and a.colid = g.smallid
36
order by a.id ,a.colorder
37
38
39
----------分页代码测试
40![]()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40