Home of DJ and technophile Jonathan Puddle (aka J Puddy)
SQL Query contraints of a database
Another useful query I was in need of, and found, yesterday. This one is care of Pinal Dave (who writes a very useful blog, which has helped me before), though I added the “Order By” line. This query lists all the constraints of a database. Replace AdventureWorks with your DB name.
USE AdventureWorks;
GO
SELECT OBJECT_NAME(OBJECT_ID) AS NameofConstraint,
SCHEMA_NAME(schema_id) AS SchemaName,
OBJECT_NAME(parent_object_id) AS TableName,
type_desc AS ConstraintType
FROM sys.objects
WHERE type_desc LIKE ‘%CONSTRAINT’
ORDER BY NameofConstraint
GO
| This entry was posted by Jonathan Puddle on July 5, 2008 at 10:14 am, and is filed under Work. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |