日期:2011-05-02 15:21:00 来源:本站整理
获得SQL Server数据字典的经典SQL语句[MSSQL防范]
本文“获得SQL Server数据字典的经典SQL语句[MSSQL防范]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
本文主要介绍了一个获得sql server数据字典的经典SQL语句,大家可以按照各自的实际情形对这段语句举行呼应的改正.
SELECT sysobjects.name AS [table], sysproperties.[value] AS 表阐明, syscolumns.name AS field, properties.[value] AS 字段阐明, systypes.name AS type, syscolumns.length, ISNULL(COLUMNPROPERTY(syscolumns.id, syscolumns.name, 'Scale'), 0) AS 小数位数, syscolumns.isnullable AS isnull, CASE WHEN syscomments.text IS NULL THEN '' ELSE syscomments.text END AS [Default], CASE WHEN COLUMNPROPERTY(syscolumns.id, syscolumns.name, 'IsIdentity') = 1 THEN '√' ELSE '' END AS 标识, CASE WHEN EXISTS (SELECT 1 FROM sysobjects WHERE xtype = 'PK' AND name IN (SELECT name FROM sysindexes WHERE indid IN (SELECT indid FROM sysindexkeys WHERE id = syscolumns.id AND colid = syscolumns.colid))) THEN '√' ELSE '' END AS 主键 FROM syscolumns INNER JOIN sysobjects ON sysobjects.id = syscolumns.id INNER JOIN systypes ON syscolumns.xtype = systypes.xtype LEFT OUTER JOIN sysproperties properties ON syscolumns.id = properties.id AND syscolumns.colid = properties.smallid LEFT OUTER JOIN sysproperties ON sysobjects.id = sysproperties.id AND sysproperties.smallid = 0 LEFT OUTER JOIN syscomments ON syscolumns.cdefault = syscomments.id WHERE (sysobjects.xtype = 'U') 以上是“获得SQL Server数据字典的经典SQL语句[MSSQL防范]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |
评论内容只代表网友观点,与本站立场无关!
评论摘要(共 0 条,得分 0 分,平均 0 分)
查看完整评论