Solved

Where is the 'unique' property and details about the columns covered by an index stored?

Posted on 2003-10-29
7
289 Views
Last Modified: 2012-08-14
Hello All,

How do I find out wether an index is unique in my sql code? Also, how can I get the names of the columns covered by an index (composite or non-composite) in plain text.

I made a fake unique non clustered index on 2 fields and from enterprise manager when I double click on the index it correctly shows that it is unique and the fields it is set on, but I can't find the table this is stored. I tried looking in the INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE table but there is no constraint entry there (isn't unique a constraint ?) Also, the closest thing to finding what columns are covered by the index is the 'keys' column in the sysindexes table but that is saved in a binary format which I don't exactly know how to convert to plain text

I have to go now because all this blue font is making me dizzy

And YES... I am smarter than the average bear

(:0)->-<
------------------------------------------------------------------------

0
Comment
Question by:YogiMySonMySon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 

Author Comment

by:YogiMySonMySon
ID: 9647850
basically my aim is to end up with a way of finding columns covered by an index and wether or not it is unique through Transact-SQL
0
 
LVL 34

Accepted Solution

by:
arbert earned 50 total points
ID: 9647897
Does:

sp_helpidex 'tablename'

return all the information you need?  Of course, since you are smarter than the average bear (lol), you can insert the results of the procedure into a temp table and use it however you need it...

Brett
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9651908
Brett,

There is a typo there, it should be:
sp_helpindex 'tablename'

Can you remind me the syntax to insert the data from a stored procedure into a temporary table, I cannot seem to figure it out.  I know it is something like:

Select * Into #Temp From exec sp_helpindex 'tablename'

But that is not right.

Anthony
As Winnie-the-Pooh would say, "I am a bear with a very small brain"
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 34

Expert Comment

by:arbert
ID: 9653290
oops...

Not that easy, you have to create the table first, then issue the insert.

create table blah (
whatever
)

insert into blah
exec sp_helpindex


tigger
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9653447
"I see" said the blind man.

Thanks,
Anthony
0
 

Author Comment

by:YogiMySonMySon
ID: 9655150
Thanks for the help mate. Sorry I did not reply yesterday, I had to pick someone up.



0
 
LVL 34

Expert Comment

by:arbert
ID: 9655298
That's cool.  Wasn't sure if that would do what you needed or not.

Brett
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question