查询sql数据库中的所有表和表描述
获取数据库中所有的表
select name as tablename, isnull((select  value from  ded_properties where sysobjects.id=major_id and minor_id=0),'') as tabledesc
from sysobjects where type='U' and name<>'sysdiagrams'
根据表明,获取字段名
SELECT
(case lorder=1 then d.name else '' end) N'tablename',
a.name N'fieldname',
(case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then '1'else '0'
end) N'IsIdentity',
(case when (SELECT count(*)
FROM sysobjects
WHERE (name in
(SELECT name
FROM sysindexes
WHERE (id = a.id) AND (indid in
(SELECT indid
FROM sysindexkeys
WHERE (id = a.id) AND (colid in
(SELECT colid
FROM syscolumns
WHERE (id = a.id) AND (name = a.name))))))) AND
(xtype = 'PK'))>0 then '1' else '0' end) N'primarykey',
b.name N'type',
a.length N'size',
COLUMNPROPERTY(a.id,a.name,'PRECISION') as N'length',
isnull(COLUMNPROPERTY(a.id,a.name,'Scale'),0) as N'Decimalplaces',
(case when a.isnullable=1 then '1'else '0' end) N'Allowair',
,'') N'defaultvalue',
isnull(g.[value],'') AS N'desc'
FROM syscolumns a
left join systypes b
pe=b.xusertype
inner join sysobjects d
on a.id=d.id pe='U' and d.name<>'dtproperties'
sql中select是什么意思
left join syscomments e
on a.cdefault=e.id
left ded_properties g
on a.id=g.major_id lid = g.minor_id
where
order by object_name(a.id),a.colorder

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。