Groups | Blog | Home
all groups > sql server (alternate) > october 2005 >

sql server (alternate) : Information Schema Query Question


boblotz2001 NO[at]SPAM yahoo.com
10/31/2005 12:25:13 PM
select t.table_name, t.constraint_type, t.constraint_name,
c.column_name
from information_schema.TABLE_CONSTRAINTS t
join information_schema.CONSTRAINT_COLUMN_USAGE c ON t.constraint_name
= c.constraint_name
where constraint_type IN ('UNIQUE', 'PRIMARY KEY')
and t.table_name = <Table Name>

[quoted text, click to view]
Akintoye Olorode
10/31/2005 2:57:56 PM
Hello All,

Could someone help provide a query that I can run to
determine the primary key and unique columns for any
given table ?

Thanks in Advance,

Akintoye

AddThis Social Bookmark Button