当前位置:七道奇文章资讯数据防范MSSQL防范
日期: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防范]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
  • 获得SQL Server元数据的几种办法
  • 获得SQL Server数据字典的经典SQL语句
  • 获得SQL Server的当前衔接数
  • 获得SQL Server日期而不包含时间的办法
  • 教您若何获得SQL字段默许值
  • 本文地址: 与您的QQ/BBS好友分享!
    • 好的评价 如果您觉得此文章好,就请您
        0%(0)
    • 差的评价 如果您觉得此文章差,就请您
        0%(0)

    文章评论评论内容只代表网友观点,与本站立场无关!

       评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
    Copyright © 2020-2022 www.xiamiku.com. All Rights Reserved .