|
Execute the following
Microsoft SQL Server T-SQL database administration script to list the definition of database objects:
USE AdventureWorks;
SELECT DISTINCT o.name AS [Object Name],
CASE
WHEN o.xtype = 'C' THEN 'CHECK constraint'
WHEN o.xtype = 'D' THEN 'Default or DEFAULT constraint'
WHEN o.xtype = 'F' THEN 'FOREIGN KEY constraint'
WHEN o.xtype = 'L' THEN 'Log'
WHEN o.xtype = 'FN' THEN 'Scalar function'
WHEN o.xtype = 'IF' THEN 'In-line table-function'
WHEN o.xtype = 'P' THEN 'Stored procedure'
WHEN o.xtype = 'PK' THEN 'PRIMARY KEY constraint (type is K)'
WHEN o.xtype = 'RF' THEN 'Replication filter stored procedure'
WHEN o.xtype = 'TF' THEN 'Table function'
WHEN o.xtype = 'TR' THEN 'Trigger'
WHEN o.xtype = 'UQ' THEN 'UNIQUE constraint (type is K)'
WHEN o.xtype = 'V' THEN 'View'
WHEN o.xtype = 'X' THEN 'Extended stored procedure'
ELSE NULL
END AS [Object Type],
o.id AS ObjectID,
TEXT AS Definition
FROM sysobjects o
JOIN syscomments c
ON o.id = c.id
WHERE o.category = 0
AND o.xtype not in ('U','S')
ORDER BY [Object Type],
[Object Name];
/* Object Name Object Type ObjectID Definition
CK_BillOfMaterials_BOMLevel CHECK constraint 309576141 ([ProductAssemblyID] IS NULL AND [BOMLevel]=(0) AND [PerAssemblyQty]=(1.00) OR [ProductAssemblyID] IS NOT NULL AND [BOMLevel]>=(1))
CK_BillOfMaterials_EndDate CHECK constraint 277576027 ([EndDate]>[StartDate] OR [EndDate] IS NULL)
CK_BillOfMaterials_PerAssemblyQty CHECK constraint 325576198 ([PerAssemblyQty]>=(1.00))
*/
Related article:
http://www.sqlusa.com/bestpractices2008/objectdefinition/
|