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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 INDEX_COL simple question

Author  Topic 

hvdtol
Yak Posting Veteran

50 Posts

Posted - 2008-02-02 : 09:08:42
Hello,

I am playing around with the INDEX_COL fucntion and something i don`t understand. Sometimes i do not get the indexed column, while i am sure there is one.
It`s a simple query, maybe somebody knows what is wrong.

USE AdventureWorks;
GO
SELECT INDEX_COL (N'AdventureWorks.Person.Address', 1,1) ;
--This shows column name AddressID

but.........
select * from sys.objects where name = 'Address'
--result is: object id = 53575229
SELECT INDEX_COL(OBJECT_NAME(object_id),1,1)
from sys.objects where object_id = 53575229
.......>>>> shows nothing ??

Can somebody explain to me why?

Best regards,

hvdtol

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-02-02 : 21:42:58
Tried this?

SELECT INDEX_COL(OBJECT_NAME(53575229),1,1)
from sys.objects where object_id = 53575229
Go to Top of Page

hvdtol
Yak Posting Veteran

50 Posts

Posted - 2008-02-03 : 05:15:43
Yes, i tried this, not output

hvdtol
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-02-03 : 13:40:50
Tried myself, this one works:

EXEC ('SELECT INDEX_COL(''AdventureWorks.Person.'' + OBJECT_NAME(53575229), 1, 1)')
Go to Top of Page
   

- Advertisement -