Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get the columns in UNIQUE CONSTRAINT

Status
Not open for further replies.

SteveDingle

Programmer
Jul 26, 2004
254
GB
Hello All,

Is there a way I can find out the column(s) defined in a UNIQUE CONSTRAINT for a specific table

Thanks,
Steve
 
Yup:
Code:
select *
from information_schema.key_column_usage
where table_name = 'tablename'
	and constraint_name in
	(	select constraint_name
		 from information_schema.table_constraints
		 where constraint_type in ('UNIQUE')
	)
Wanna include primary keys as well, add [!],'PRIMARY KEY'[/!] after 'UNIQUE'

------
[small]<this is sig>
select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')
</this is sig>[/small]
[banghead]
 
Thanks vongrunt. Perfect!

Would you know of a resource (online books section or whitepaper) which would give me the various ways, like this, of getting this type of information

Thanks again

Toodles,
Steve Dingle
D&S Business Solutions Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top