Home > Archive > Microsoft SQL Server forum > October 2005 > Information Schema Query Question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Information Schema Query Question
Akintoye Olorode

2005-10-31, 8:24 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


boblotz2001@yahoo.com

2005-10-31, 8:24 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_US
AGE c ON t.constraint_name
= c.constraint_name
where constraint_type IN ('UNIQUE', 'PRIMARY KEY')
and t.table_name = <Table Name>

Akintoye Olorode wrote:
> 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


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com