天下网吧 >> 网吧天地 >> 网吧技术 >> 网吧软件 >> 正文

将SQL中所有表的列信息显示出来

2009-1-9不详佚名

将SQL Server中所有表的列信息显示出来:

以下为引用的内容:

SELECT SysObjects.Name as tb_name, SysColumns.Name as col_name,

SysTypes.Name as col_type, SysColumns.Length as col_len, isnull

(SysProperties.Value,SysColumns.Name) as col_memo,
case when SysColumns.name in
(select 主键=a.name
FROM syscolumns a
inner join sysobjects b on a.id=b.id and

b.xtype='U' and b.name<>'dtproperties'
where 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
)))
and b.name=SysObjects.Name
)
then 1 else 0 end as is_key

FROM SysObjects,SysTypes,SysColumns

LEFT JOIN SysProperties ON (Syscolumns.Id = Sysproperties.Id AND

Syscolumns.Colid = Sysproperties.Smallid)

WHERE (Sysobjects.Xtype ='u' OR Sysobjects.Xtype ='v')
AND Sysobjects.Id = Syscolumns.Id AND SysTypes.XType = Syscolumns.XType

AND SysTypes.Name <> 'sysname' AND Sysobjects.

Name Like '%' ORDER By SysObjects.Name, SysColumns.colid

本文来源:不详 作者:佚名

声明
声明:本站所发表的文章、评论及图片仅代表作者本人观点,与本站立场无关。文章是出于传递更多信息之目的。若有来源标注错误或侵犯了您的合法权益,请作者持权属证明与本网联系,我们将及时更正、删除,谢谢。 Email:support@txwb.com,系统开号,技术支持,服务联系微信:_WX_1_本站所有有注明来源为天下网吧或天下网吧论坛的原创作品,各位转载时请注明来源链接!
天下网吧·网吧天下
  • 本周热门
  • 本月热门
  • 阅读排行