清楚其關系了就可以隨心所欲的運用了 如:SQL2005中取得指定表的所有字段名的屬性、描述 select rtrim(b.name) as ColName ,isnull(c.value,'') as Descript ,case when h.id is not null then 'PK' else '' end as PrimaryKey ,type_name(b.xusertype) + case when b.colstat & 1 = 1 then '[ID(' + convert(varchar,ident_seed(a.name)) + ',' + convert(varchar,ident_incr(a.name)) + ')]' else '' end as [Type] ,b.Length ,case b.isnullable when 0 then 'N' else 'Y' end as [IsNull] ,isnull(e.text,'') as [Default] from sys.sysobjects a,sys.syscolumns b left outer join sys.extended_properties c on b.id = c.major_id and b.colid = c.minor_id left outer join sys.syscomments e on b.cdefault = e.id left outer join (select g.id,g.colid from sys.sysindexes f,sys.sysindexkeys g where f.id = g.id and f.indid = g.indid and f.indid > 0 and f.indid < 255 and (f.status & 2048)<>0) h on b.id = h.id and b.colid = h.colid where a.id = b.id and a.id = object_id('你要查詢的表名') order by b.colid
syscharsets 主数据库 字符集与排序顺序
sysconfigures 主数据库 配置选项
syscurconfigs 主数据库 当前配置选项
sysdatabases 主数据库 服务器中的数据库
syslanguages 主数据库 语言
syslogins 主数据库 登陆帐号信息
sysoledbusers 主数据库 链接服务器登陆信息
sysprocesses 主数据库 进程
sysremotelogins主数据库 远程登录帐号syscolumns 每个数据库 列
sysconstrains 每个数据库 限制
sysfilegroups 每个数据库 文件组
sysfiles 每个数据库 文件
sysforeignkeys 每个数据库 外部关键字
sysindexs 每个数据库 索引
sysmenbers 每个数据库 角色成员
sysobjects 每个数据库 所有数据库对象
syspermissions 每个数据库 权限
systypes 每个数据库 用户定义数据类型
sysusers 每个数据库 用户
如:SQL2005中取得指定表的所有字段名的屬性、描述
select rtrim(b.name) as ColName
,isnull(c.value,'') as Descript
,case when h.id is not null then 'PK' else '' end as PrimaryKey
,type_name(b.xusertype) + case when b.colstat & 1 = 1 then '[ID(' + convert(varchar,ident_seed(a.name)) + ',' + convert(varchar,ident_incr(a.name)) + ')]' else '' end as [Type]
,b.Length
,case b.isnullable when 0 then 'N' else 'Y' end as [IsNull]
,isnull(e.text,'') as [Default]
from sys.sysobjects a,sys.syscolumns b
left outer join sys.extended_properties c on b.id = c.major_id and b.colid = c.minor_id
left outer join sys.syscomments e on b.cdefault = e.id
left outer join (select g.id,g.colid from sys.sysindexes f,sys.sysindexkeys g
where f.id = g.id and f.indid = g.indid and f.indid > 0 and f.indid < 255 and (f.status & 2048)<>0) h on b.id = h.id and b.colid = h.colid
where a.id = b.id
and a.id = object_id('你要查詢的表名')
order by b.colid