Two views of the Check constraint information in the query library (SQL Server)

xiaoxiao2021-03-06  41

The following two views are based on the system table sysObjects, syscomments, and system view sysConstraints, including table ID, table name, column ID, column name, check constraint ID, check, check, check constraints, and Check constraints, and Check constraints. TccView is Table-Column-Check View, all of which are column Check constraints, TcView is Table-Check View, and all of the table-level Check constraints are in the results. For the role of the value of the field status, see the attribute settings of the Check constraint without using the Enterprise Manager. Below is the code of two views, which can be used in any database in the SQL Server 2000 database.

TccView: Select Top 100 Percent A.id As TableId, A.Tables, A.Colid, A.ColumnName, A.DataType, A.Length, B.constid As Checkid, B.Checkname, B.status, B.ContentFrom SELECT sysobjects.name AS tablename, sysobjects.id, syscolumns.name AS columnname, syscolumns.colid, systypes.name AS datatype, syscolumns.length AS length FROM sysobjects, syscolumns, systypes WHERE sysobjects.xtype = 'u' AND sysobjects.id = syscolumns.id AND syscolumns.xtype = systypes.xtype AND systypes.xtype = systypes.xusertype AND sysobjects.status> 0) a LEFT OUTER JOIN (SELECT sysobjects.name checkname, sysobjects.status, sysconstraints.constid, sysconstraints.id, sysconstraints.colid, syscomments.text AS content FROM sysobjects, sysconstraints, syscomments WHERE xtype = 'c' AND sysobjects.id = sysconstraints.constid AND sysconstraints.constid = syscomments.id) b ON a.id = b.id AN D a.colid = b.colidorder by a.tablename, A.ColumnName, B.checknametcview: Select A.id As TableId, A.Tablename, B. Constid As Checkid, B.Checkname, B.status, B.ContentFrom SELECT sysobjects.id, sysobjects.name AS tablename FROM sysobjects WHERE sysobjects.xtype = 'u' AND sysobjects.status> 0) a LEFT OUTER JOIN (SELECT sysobjects.name checkname, sysobjects.status, sysconstraints.constid, sysconstraints.id, Sysconstraints.colid, syscomments.text as content from sysobjects, sysconstraints, syscomments where xtype = 'c' and sysobjects.id =

转载请注明原文地址:https://www.9cbs.com/read-72872.html

New Post(0)