Returns the name of the indexed column in the specified table or view, and can be up to 255 bytes in length
index_col (object_name, index_id, key_# [, user_id])
is the name of a table or view. The name can be fully qualified (that is, it can include the database and owner name). It must be enclosed in quotes.
is the number of object_name’s index. This number is the same as the value of sysindexes.indid.
is a key in the index. This value is between 1 and sysindexes.keycnt for a clustered index and between 1 and sysindexes.keycnt+1 for a nonclustered index.
is the owner of object_name. If you do not specify user_id, it defaults to the caller’s user ID.
Finds the names of the keys in the clustered index on table t4:
declare @keycnt integer select @keycnt = keycnt from sysindexes where id = object_id("t4") and indid = 1 while @keycnt > 0 begin select index_col("t4", 1, @keycnt) select @keycnt = @keycnt - 1 end
index_col, a system function, returns the name of the indexed column.
index_col returns NULL if object_name is not a table or view name.
For general information about system functions, see “String functions”.
ANSI SQL – Compliance level: Transact-SQL extension.
Any user can execute index_col.
Function object_id
System procedure sp_helpindex
Copyright © 2005. Sybase Inc. All rights reserved. |