获取MSSQL数据字典的SQL语句nba买球

作者:计算机教程

复制代码 代码如下:CREATE VIEW dbo.vw_db_dictionary AS SELECT TOP 100 PERCENT dbo.sysobjects.name AS table_name, dbo.sysproperties.[value] AS table_desc, dbo.syscolumns.name AS field, properties.[value] AS field_desc, dbo.systypes.name AS field_type, dbo.syscolumns.length AS field_size, ISNULL(COLUMNPROPERTY(dbo.syscolumns.id, dbo.syscolumns.name, 'Scale'), 0) AS field_precision, dbo.syscolumns.isnullable AS nullable, CASE WHEN syscomments.text IS NULL THEN '' ELSE syscomments.text END AS default_value, CASE WHEN COLUMNPROPERTY(syscolumns.id, syscolumns.name, 'IsIdentity') = 1 THEN '√' ELSE '' END AS is_identity, 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 is_key FROM dbo.syscolumns INNER JOIN dbo.sysobjects ON dbo.sysobjects.id = dbo.syscolumns.id INNER JOIN dbo.systypes ON dbo.syscolumns.xtype = dbo.systypes.xtype LEFT OUTER JOIN dbo.sysproperties properties ON dbo.syscolumns.id = properties.id AND dbo.syscolumns.colid = properties.smallid LEFT OUTER JOIN dbo.sysproperties ON dbo.sysobjects.id = dbo.sysproperties.id AND dbo.sysproperties.smallid = 0 LEFT OUTER JOIN dbo.syscomments ON dbo.syscolumns.cdefault = dbo.syscomments.id WHERE (dbo.sysobjects.xtype = 'U') ORDER BY dbo.sysobjects.name

nba买球 1SELECT sysobjects.name AS [table], sysproperties.[value] AS 表说明, 
nba买球 2      syscolumns.name AS field, properties.[value] AS 字段说明, systypes.name AS type, 
nba买球 3      syscolumns.length, ISNULL(COLUMNPROPERTY(syscolumns.id, syscolumns.name, 
nba买球 4      'Scale'), 0) AS 小数位数, syscolumns.isnullable AS isnull, 
nba买球 5      CASE WHEN syscomments.text IS NULL 
nba买球 6      THEN '' ELSE syscomments.text END AS [Default], 
nba买球 7nba买球,      CASE WHEN COLUMNPROPERTY(syscolumns.id, syscolumns.name, 'IsIdentity') 
nba买球 8      = 1 THEN '√' ELSE '' END AS 标识, CASE WHEN EXISTS
nba买球 9          (SELECT 1
nba买球 10         FROM sysobjects
nba买球 11         WHERE xtype = 'PK' AND name IN
nba买球 12                   (SELECT name
nba买球 13                  FROM sysindexes
nba买球 14                  WHERE indid IN
nba买球 15                            (SELECT indid
nba买球 16                           FROM sysindexkeys
nba买球 17                           WHERE id = syscolumns.id AND colid = syscolumns.colid))) 
nba买球 18      THEN '√' ELSE '' END AS 主键
nba买球 19FROM syscolumns INNER JOIN
nba买球 20      sysobjects ON sysobjects.id = syscolumns.id INNER JOIN
nba买球 21      systypes ON syscolumns.xtype = systypes.xtype LEFT OUTER JOIN
nba买球 22      sysproperties properties ON syscolumns.id = properties.id AND 
nba买球 23      syscolumns.colid = properties.smallid LEFT OUTER JOIN
nba买球 24      sysproperties ON sysobjects.id = sysproperties.id AND 
nba买球 25      sysproperties.smallid = 0 LEFT OUTER JOIN
nba买球 26      syscomments ON syscolumns.cdefault = syscomments.id
nba买球 27WHERE (sysobjects.xtype = 'U') 
nba买球 28

本文由nba买球发布,转载请注明来源

关键词: