A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z  special characters  sybase-tech-blog


Category: ASE: Functions: System Functions

index_col()

The System Function index_col() returns the name of the indexed column of a table or view specified in the function parameters. The output can be up to 255 bytes large. The function index_col() is a Transact-SQL extension and can be executed by any user.

Syntax of the System Function index_col()

    index_col(object_name, index_id, key_number [, user_id])
    

The parameters of the System Function index_col()

"object_name"
The parameter "object_name" is the name of the object, in this case of the table, or view of a database. The name of an object is stored in the column "name" of the system table sysobjects. The parameter "object_name" must be specified in quotes. In addition, the fully qualified object name, using the database name and object owner name can be used.

"index_id"
the parameter "index_id" is the identification number of the object, i.e. of the "object_name" referenced in the parameter. The "index_id" is stored in the column "indid" of the system table sysindexes

"key_number"
The parameter "key_number" references a key in an index. This value for a clustered index is between 1 and the value in the column "keycnt" in der system table sysindexes. For a nonclustered index this value is between 1 and the value in the column "keycnt"+1 of the system table sysindexes.

"user_id"
The parameter "user_id" is the identification number of the owner of the object. If the parameter "user_id" is not specified, the id of the current user is taken default value.

Example for the System Function index_col()

    declare @keycnt integer
select @keycnt = keycnt from sysindexes
where id = object_id("syslogins")
and indid = 1
while @keycnt > 0
begin
select index_col("syslogins", 1, @keycnt)
select @keycnt = @keycnt - 1
end
go
-----
suid

Returns the column name suid of the key for the clustered index on the table syslogins.

See also:

ASE T-SQL - Aggregate Functions,
audit_event_name(),
col_length(),
col_name(),
curunreservedpgs(),
datachange(),
datalength(),
data_pages(),
data_pgs(),
db_id(),
db_name(),
host_id(),
host_name(),
identity(),
index_colorder(),
isnull(),
lct_admin(),
license_enabled(),
lockscheme(),
next_identity(),
object_id(),
object_name(),
pagesize(),
pointer_size(),
ptn_data_pgs(),
reserved_pages(),
reserved_pgs(),
rowcnt(),
row_count(),
showplan_in_xml(),
syb_sendmsg(),
syb_sendmsg(),
System Functions,
tempdb_id(),
tran_dumpable_status(),
tsequal(),
used_pages(),
used_pgs().