Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Kali
Starting Member
14 Posts |
Posted - 2004-08-18 : 22:39:00
|
Hi all,I have an sql brainfart , can’t get the join straight. I am trying to join 4 systables to get the names of tables, non-clustered indexes on them and columns on which these indexes reside.Here’s the join on Northwind db:select so.name as [Table Name], SC.NAME AS [COLUMN], si.name as [Index Name], SC.NAME AS [COLUMN]from sysobjects so join syscolumns sc on so.id = sc.idjoin sysindexes si on sc.id = si.idjoin sysindexkeys sik on si.id = sik.id and sc.colid = sik.colidjoin sysfilegroups sf on sf.groupid = si.groupidwhere si.indid >1andsf.groupname = 'primary'andso.xtype = 'U'and si.name not like '_WA_Sys%'problem is, off course, that on Orders table, for example, there are only total of 9 non-clustered indexes, but I get 72 rows just for that table. It’s the join sequence I bet, but I can’t get it right .Help much appreciated |
|
|
|
|
|