Wednesday, March 21, 2012

How to find unique indexes in SQLserver 2005

How do I find unique indexes in SQLserver 2005.
Is there a website/page which does describe the information_schema and gives
tips etc.
Now I want to find all unique constraints and unique indexes in a given
database.
Thanks for your time and attention.
ben brugman
Ben,
this should do for you:
select * from sys.indexes
where is_unique = 1 or is_unique_constraint = 1
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .
|||select sysobjects.name from sysobjects join
sysindexes on sysobjects.id=sysindexes.id
where sysindexes.status=2 and type='u'
Hilary Cotter
Director of Text Mining and Database Strategy
RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.
This posting is my own and doesn't necessarily represent RelevantNoise's
positions, strategies or opinions.
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"ben brugman" <ben@.niethier.nl> wrote in message
news:uhpOyAg5GHA.2208@.TK2MSFTNGP04.phx.gbl...
> How do I find unique indexes in SQLserver 2005.
> Is there a website/page which does describe the information_schema and
> gives tips etc.
> Now I want to find all unique constraints and unique indexes in a given
> database.
> Thanks for your time and attention.
> ben brugman
>
|||Sorry, bad answer. Try this.
--unique indexes
select sysobjects.name,sysindexes.name,sysindexes.status from sysobjects
join
sysindexes on sysobjects.id=sysindexes.id
where (sysindexes.status =2 )
and type='u'
--unique constrains
select name, object_name(parent_object_id) from sys.key_constraints
where type='uq'
Hilary Cotter
Director of Text Mining and Database Strategy
RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.
This posting is my own and doesn't necessarily represent RelevantNoise's
positions, strategies or opinions.
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Hilary Cotter" <hilary.cotter@.gmail.com> wrote in message
news:uMQ8aVg5GHA.1252@.TK2MSFTNGP04.phx.gbl...
> select sysobjects.name from sysobjects join
> sysindexes on sysobjects.id=sysindexes.id
> where sysindexes.status=2 and type='u'
>
> --
> Hilary Cotter
> Director of Text Mining and Database Strategy
> RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.
> This posting is my own and doesn't necessarily represent RelevantNoise's
> positions, strategies or opinions.
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
> Looking for a FAQ on Indexing Services/SQL FTS
> http://www.indexserverfaq.com
>
> "ben brugman" <ben@.niethier.nl> wrote in message
> news:uhpOyAg5GHA.2208@.TK2MSFTNGP04.phx.gbl...
>

No comments:

Post a Comment