USE Northwind;
GO
SELECT c.table_name , c.constraint_name
FROM INFORMATION_SCHEMA.CONSTRAINT_TABLE_USAGE AS c
WHERE OBJECTPROPERTY( OBJECT_ID( c.constraint_name ) , 'IsPrimaryKey' ) = 1 And
-- Check to filter out system tables...
1 NOT IN ( OBJECTPROPERTY( OBJECT_ID( c.table_name ) , 'IsSystemTable' ) ,
OBJECTPROPERTY( OBJECT_ID( c.table_name ) , 'IsMSShipped' ) )
ORDER BY c.table_name;
/*
table_name constraint_name
-------------------- -----------------------
Categories PK_Categories
CustomerCustomerDemo PK_CustomerCustomerDemo
CustomerDemographics PK_CustomerDemographics
Customers PK_Customers
Employees PK_Employees
EmployeeTerritories PK_EmployeeTerritories
Order Details PK_Order_Details
Orders PK_Orders
Products PK_Products
Region PK_Region
Shippers PK_Shippers
Suppliers PK_Suppliers
Territories PK_Territories
*/
GO
This page was last updated on May 01, 2006 04:28 PM.