identity_burn_max  index_colorder

Chapter 2: Transact-SQL Functions

index_col

Description

Returns the name of the indexed column in the specified table or view, and can be up to 255 bytes in length

Syntax

index_col (object_name, index_id, key_# [, user_id])

Parameters

object_name

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.

index_id

is the number of object_name’s index. This number is the same as the value of sysindexes.indid.

key_#

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.

user_id

is the owner of object_name. If you do not specify user_id, it defaults to the caller’s user ID.

Examples

Example 1

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

Usage

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

Any user can execute index_col.

See also

Function object_id

System procedure sp_helpindex





Copyright © 2005. Sybase Inc. All rights reserved. index_colorder

View this book as PDF